From 587cce12ec1fe0758ecc333eda00b02c68c85d26 Mon Sep 17 00:00:00 2001 From: Can Olcer Date: Fri, 25 Mar 2022 18:16:04 +0000 Subject: [PATCH] chore: fix docker github action --- .github/workflows/docker.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e05af99..c23af0b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -21,10 +21,25 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Set Versions + uses: actions/github-script@v4 + id: set_version + with: + script: | + const tag = context.ref.substring(10) + const no_v = tag.replace('v', '') + const dash_index = no_v.lastIndexOf('-') + const no_dash = (dash_index > -1) ? no_v.substring(0, dash_index) : no_v + core.setOutput('tag', tag) + core.setOutput('no-v', no_v) + core.setOutput('no-dash', no_dash) - name: Build and push uses: docker/build-push-action@v2 with: push: true file: Dockerfile.prod - tags: shafyy/fugu:latest,shafyy/fugu:${{ github.ref_name }} \ No newline at end of file + tags: | + ${{secrets.DOCKERHUB_USERNAME}}/fugu:latest + ${{secrets.DOCKERHUB_USERNAME}}/fugu:${{steps.set_version.outputs.no-dash}} \ No newline at end of file