From 2837410a244e87e5aac3e05e66cdf77b94858e6b Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 28 Sep 2021 20:31:25 +0200 Subject: [PATCH] ci: move docker image publishing to github Closes #8330 --- .github/workflows/docker-image.yml | 34 ++++++++++++++++++++++++++++++ bin/push-docker-tags.sh | 12 +++++------ 2 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 000000000000..8d2a95a9a601 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,34 @@ +name: Publish Docker image + +on: + workflow_dispatch: + push: + branches: + - 'master' + - 'bifrost-*' + tags: + - 'v*' + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + env: + IMAGE_NAME: ipfs/go-ipfs + WIP_IMAGE_TAG: wip + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Build wip Docker image + run: docker build -t $IMAGE_NAME:$WIP_IMAGE_TAG . + + - name: Log in to Docker Hub + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Publish Docker Image to Docker Hub + run: ./bin/push-docker-tags.sh $(date -u +%F) + diff --git a/bin/push-docker-tags.sh b/bin/push-docker-tags.sh index 91d06a427f28..00d314c07a8c 100755 --- a/bin/push-docker-tags.sh +++ b/bin/push-docker-tags.sh @@ -29,18 +29,18 @@ # set -euo pipefail -if [[ $# -lt 3 ]] ; then - echo 'At least 3 args required. Pass 5 args for a dry run.' +if [[ $# -lt 1 ]] ; then + echo 'At least 1 arg required. Pass 5 args for a dry run.' echo 'Usage:' - echo './push-docker-tags.sh [git tag name] [dry run]' + echo './push-docker-tags.sh [git commit sha1] [git branch name] [git tag name] [dry run]' exit 1 fi BUILD_NUM=$1 -GIT_SHA1=$2 +GIT_SHA1=${2:-$(git rev-parse HEAD)} GIT_SHA1_SHORT=$(echo "$GIT_SHA1" | cut -c 1-7) -GIT_BRANCH=$3 -GIT_TAG=${4:-""} +GIT_BRANCH=${3:-$(git symbolic-ref -q --short HEAD || echo "unknown")} +GIT_TAG=${4:-$(git describe --tags --exact-match || echo "")} DRY_RUN=${5:-false} WIP_IMAGE_TAG=${WIP_IMAGE_TAG:-wip}