From 316926a6b5820ff43badca4a06d3e976650b3324 Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Tue, 21 Dec 2021 17:11:27 +0530 Subject: [PATCH 1/5] Release docker image using branch. --- .github/workflows/publish.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 577a528..5839c3c 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -7,19 +7,19 @@ jobs: name: Push Docker image to Docker Hub runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 - name: Get the version id: vars run: | - echo ::set-output name=sha::$(echo ${GITHUB_SHA:0:7}) echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/}) - - name: Docker Login to Github Registry + echo ::set-output name=branch::$(echo ${GITHUB_REF##*/}) + - name: Docker Login run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin - - name: Docker Pull - run: docker pull docker.pkg.github.com/vulcanize/eth-statediff-service/eth-statediff-service:${{steps.vars.outputs.sha}} - - name: Docker Login to Docker Registry - run: echo ${{ secrets.VULCANIZEJENKINS_PAT }} | docker login -u vulcanizejenkins --password-stdin - - name: Tag docker image - run: docker tag docker.pkg.github.com/vulcanize/eth-statediff-service/eth-statediff-service:${{steps.vars.outputs.sha}} vulcanize/eth-statediff-service:${{steps.vars.outputs.tag}} - - name: Docker Push to Docker Hub - run: docker push vulcanize/eth-statediff-service:${{steps.vars.outputs.tag}} - + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: vulcanize/eth-statediff-service:${{ steps.vars.outputs.tag }} + build-args: | + BRANCH=${{ steps.vars.outputs.branch }} From a99b1975e4f4b96611c15491a43d1845a53d3318 Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Tue, 21 Dec 2021 17:37:01 +0530 Subject: [PATCH 2/5] Small fix. --- .github/workflows/publish.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 5839c3c..7f54ee0 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -15,11 +15,11 @@ jobs: echo ::set-output name=branch::$(echo ${GITHUB_REF##*/}) - name: Docker Login run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: . - push: true - tags: vulcanize/eth-statediff-service:${{ steps.vars.outputs.tag }} - build-args: | - BRANCH=${{ steps.vars.outputs.branch }} + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: vulcanize/eth-statediff-service:${{ steps.vars.outputs.tag }} + build-args: | + BRANCH=${{ steps.vars.outputs.branch }} From 0ff60a69da09f39dba38242f80397d07412cee45 Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Tue, 21 Dec 2021 18:12:22 +0530 Subject: [PATCH 3/5] Small fix. --- .github/workflows/publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 7f54ee0..6be38c3 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -12,7 +12,7 @@ jobs: id: vars run: | echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/}) - echo ::set-output name=branch::$(echo ${GITHUB_REF##*/}) + echo ::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/}) - name: Docker Login run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin - name: Build and push From e08d31e2427de0aa2d889b1734ad087e2f9992c9 Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Tue, 21 Dec 2021 18:33:52 +0530 Subject: [PATCH 4/5] Use branch name. --- .github/workflows/publish.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 6be38c3..f017698 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -9,10 +9,12 @@ jobs: steps: - uses: actions/checkout@v2 - name: Get the version + run: echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/}) id: vars - run: | - echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/}) - echo ::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/}) + - name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_BASE_REF#refs/heads/})" + id: extract_branch - name: Docker Login run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin - name: Build and push @@ -22,4 +24,4 @@ jobs: push: true tags: vulcanize/eth-statediff-service:${{ steps.vars.outputs.tag }} build-args: | - BRANCH=${{ steps.vars.outputs.branch }} + BRANCH=${{ steps.extract_branch.outputs.branch }} From 747c5f540050f4e47d334e0ab7ccf2c1ac0f5c9f Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Thu, 23 Dec 2021 19:51:06 +0530 Subject: [PATCH 5/5] Use commit hash to build docker image and publish. --- .github/workflows/publish.yaml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index f017698..c673a8c 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -9,14 +9,15 @@ jobs: steps: - uses: actions/checkout@v2 - name: Get the version - run: echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/}) + run: | + echo ::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/}) + echo ::set-output name=sha::$(echo ${GITHUB_SHA}) id: vars - - name: Extract branch name - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_BASE_REF#refs/heads/})" - id: extract_branch - - name: Docker Login - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin + - name: Docker Login to Docker Registry + uses: docker/login-action@v1 + with: + username: vulcanizejenkins + password: ${{ secrets.VULCANIZEJENKINS_PAT }} - name: Build and push uses: docker/build-push-action@v2 with: @@ -24,4 +25,5 @@ jobs: push: true tags: vulcanize/eth-statediff-service:${{ steps.vars.outputs.tag }} build-args: | - BRANCH=${{ steps.extract_branch.outputs.branch }} + GIT_COMMIT=${{ steps.vars.outputs.sha }} +