From e275bd6bf30598886a3e6a1426b49d97791a2759 Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Thu, 28 Jan 2021 01:48:29 +0800 Subject: [PATCH] workflow: update docker action for tag trigger --- .github/workflows/docker.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0cb3b7e..312d7ed 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,9 +3,10 @@ name: docker on: push: branches: master + tags: "*" jobs: - docker: + build: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 @@ -25,6 +26,19 @@ jobs: with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Determine docker tags + id: docker_tag + run: | + case $GITHUB_REF in + refs/tags/*) + TAG_NAME=${GITHUB_REF#refs/tags/} + echo ::set-output name=DOCKER_TAG::tsl0922/ttyd:${TAG_NAME} + echo ::set-output name=ALPINE_TAG::tsl0922/ttyd:${TAG_NAME}-alpine + ;; + *) + echo ::set-output name=DOCKER_TAG::tsl0922/ttyd:latest + echo ::set-output name=ALPINE_TAG::tsl0922/ttyd:alpine + esac - name: build/push docker image uses: docker/build-push-action@v2 with: @@ -32,8 +46,7 @@ jobs: file: ./Dockerfile platforms: linux/amd64,linux/arm64 push: true - tags: | - tsl0922/ttyd:latest + tags: ${{ steps.docker_tag.outputs.DOCKER_TAG }} - name: build/push docker image (alpine) uses: docker/build-push-action@v2 with: @@ -41,5 +54,4 @@ jobs: file: ./Dockerfile.alpine platforms: linux/amd64,linux/arm64 push: true - tags: | - tsl0922/ttyd:alpine \ No newline at end of file + tags: ${{ steps.docker_tag.outputs.ALPINE_TAG }} -- 2.43.4