From b89fc3163a4eb2adf00c39e464a73eae2a7ac58b Mon Sep 17 00:00:00 2001 From: Bradley Bown Date: Thu, 17 Oct 2024 21:18:45 +0100 Subject: [PATCH] Commit tag from current branch, fix tags env var --- .github/workflows/coordinator-build-and-publish.yml | 2 +- .github/workflows/main.yml | 2 +- .github/workflows/reuse-store-image-name-and-tags.yml | 3 +-- .github/workflows/traces-api-facade-build-and-publish.yml | 6 +++++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/coordinator-build-and-publish.yml b/.github/workflows/coordinator-build-and-publish.yml index b4bec8edf..b521cff10 100644 --- a/.github/workflows/coordinator-build-and-publish.yml +++ b/.github/workflows/coordinator-build-and-publish.yml @@ -47,7 +47,7 @@ jobs: - name: Set develop tag if main branch if: ${{ github.ref == 'refs/heads/main' }} run: | - echo "TAGS=" >> $GITHUB_ENV + echo "TAGS=${{ inputs.image_name }}:${{ inputs.commit_tag }},${{ inputs.image_name }}:${{ inputs.develop_tag }}" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v4 - uses: actions/setup-java@v4 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b17383c82..4e175d675 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -184,7 +184,7 @@ jobs: publish-images-after-run-tests-success-on-main: needs: [ store-image-name-and-tags, testing, run-e2e-tests, run-e2e-tests-geth-tracing ] - if: ${{ always() && github.ref != 'refs/heads/main' && needs.testing.result == 'success' && needs.run-e2e-tests.outputs.tests_outcome == 'success' && needs.run-e2e-tests-geth-tracing.outputs.tests_outcome == 'success' }} + if: ${{ always() && github.ref == 'refs/heads/main' && needs.testing.result == 'success' && needs.run-e2e-tests.outputs.tests_outcome == 'success' && needs.run-e2e-tests-geth-tracing.outputs.tests_outcome == 'success' }} uses: ./.github/workflows/build-and-publish.yml with: push_image: true diff --git a/.github/workflows/reuse-store-image-name-and-tags.yml b/.github/workflows/reuse-store-image-name-and-tags.yml index 5a8669289..b4acc031a 100644 --- a/.github/workflows/reuse-store-image-name-and-tags.yml +++ b/.github/workflows/reuse-store-image-name-and-tags.yml @@ -19,7 +19,6 @@ jobs: name: Compute version tags env: # REF_NAME: ${{ github.ref_name }} - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} EVENT_BEFORE: ${{ github.event.before }} outputs: commit_tag: ${{ steps.step1.outputs.COMMIT_TAG }} @@ -31,7 +30,7 @@ jobs: - name: Compute version tags id: step1 run: | - echo COMMIT_TAG=$(git rev-parse --short "$GITHUB_SHA") >> $GITHUB_OUTPUT + echo COMMIT_TAG=$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT echo LAST_COMMIT_TAG=$(git rev-parse --short "${{ env.EVENT_BEFORE }}") >> $GITHUB_OUTPUT echo DEVELOP_TAG=develop >> $GITHUB_OUTPUT - name: Show version tags diff --git a/.github/workflows/traces-api-facade-build-and-publish.yml b/.github/workflows/traces-api-facade-build-and-publish.yml index 13081ff1d..e4b02883e 100644 --- a/.github/workflows/traces-api-facade-build-and-publish.yml +++ b/.github/workflows/traces-api-facade-build-and-publish.yml @@ -44,6 +44,10 @@ jobs: PUSH_IMAGE: ${{ inputs.push_image }} TAGS: ${{ inputs.image_name }}:${{ inputs.commit_tag }} steps: + - name: Set develop tag if main branch + if: ${{ github.ref == 'refs/heads/main' }} + run: | + echo "TAGS=${{ inputs.image_name }}:${{ inputs.commit_tag }},${{ inputs.image_name }}:${{ inputs.develop_tag }}" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v3 with: @@ -107,6 +111,6 @@ jobs: file: ./traces-api-facade/Dockerfile platforms: linux/amd64,linux/arm64 push: ${{ env.PUSH_IMAGE }} - tags: ${{ inputs.image_name }}:${{ inputs.commit_tag }},${{ inputs.image_name }}:${{ inputs.develop_tag }} + tags: ${{ env.TAGS }} cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max