Skip to content

Merge pull request #2801 from bitshares/release #1222

Merge pull request #2801 from bitshares/release

Merge pull request #2801 from bitshares/release #1222

Workflow file for this run

name: Docker
on: [ push, pull_request ]
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Decide whether to push to DockerHub, and set tag
if: |
github.event_name == 'push' &&
( startsWith( github.ref, 'refs/tags/' ) ||
contains( fromJSON('["master","develop","testnet","hardfork"]'), github.ref_name ) )
run: |
if [ "${GITHUB_REF_NAME}" == "master" ] ; then
DOCKER_PUSH_TAG=latest
else
DOCKER_PUSH_TAG=${GITHUB_REF_NAME}
fi
echo "DOCKER_PUSH_TAG=${DOCKER_PUSH_TAG}"
echo "DOCKER_PUSH_TAG=${DOCKER_PUSH_TAG}" >> $GITHUB_ENV
VERSION_MAJOR=`echo "${DOCKER_PUSH_TAG}" | cut -f1 -d'.'`
if [ "${VERSION_MAJOR}" != "${DOCKER_PUSH_TAG}" ]; then
VERSION_MINOR=`echo "${DOCKER_PUSH_TAG}" | cut -f2 -d'.'`
DOCKER_PUSH_TAG_SHORT=${VERSION_MAJOR}.${VERSION_MINOR}
if [ "${DOCKER_PUSH_TAG_SHORT}" != "${DOCKER_PUSH_TAG}" ]; then
echo "DOCKER_PUSH_TAG_SHORT=${DOCKER_PUSH_TAG_SHORT}"
echo "DOCKER_PUSH_TAG_SHORT=${DOCKER_PUSH_TAG_SHORT}" >> $GITHUB_ENV
fi
fi
- name: Test tag
if: env.DOCKER_PUSH_TAG != ''
run: echo "${DOCKER_PUSH_TAG}"
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build only
uses: docker/build-push-action@v4
with:
context: .
load: true
- name: Login to DockerHub
if: env.DOCKER_PUSH_TAG != ''
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push to DockerHub (for branches)
if: env.DOCKER_PUSH_TAG != '' && env.DOCKER_PUSH_TAG_SHORT == ''
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_REPO_PATH }}:${{ env.DOCKER_PUSH_TAG }}
- name: Push to DockerHub (for tags)
if: env.DOCKER_PUSH_TAG != '' && env.DOCKER_PUSH_TAG_SHORT != ''
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ secrets.DOCKERHUB_REPO_PATH }}:${{ env.DOCKER_PUSH_TAG }}
${{ secrets.DOCKERHUB_REPO_PATH }}:${{ env.DOCKER_PUSH_TAG_SHORT }}