From 4cd14b0ef9901c1270fe46e731bab65c927f4c6a Mon Sep 17 00:00:00 2001 From: Javier Cortejoso Date: Fri, 28 Jun 2024 09:58:27 +0200 Subject: [PATCH] Update docker-build-scan.yaml Improving the docker tagging logic. [Context](https://github.com/orgs/community/discussions/25191) (thanks @alvarof2 for the link) --- .github/workflows/docker-build-scan.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-build-scan.yaml b/.github/workflows/docker-build-scan.yaml index 470067488888..fde736c0967b 100644 --- a/.github/workflows/docker-build-scan.yaml +++ b/.github/workflows/docker-build-scan.yaml @@ -25,6 +25,8 @@ jobs: build-cel2-migration-tool: runs-on: ubuntu-latest + env: + GIT_COMMIT: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} needs: detect-files-changed if: | contains(needs.detect-files-changed.outputs.files-changed, 'op-chain-ops/cmd/celo-migrate') || @@ -48,7 +50,7 @@ jobs: with: platforms: linux/amd64 registry: us-west1-docker.pkg.dev/devopsre/dev-images/cel2-migration-tool - tags: ${{ github.sha }} + tags: ${{ env.GIT_COMMIT }} context: ./ dockerfile: ./op-chain-ops/Dockerfile push: true @@ -72,9 +74,9 @@ jobs: id-token: write security-events: write env: - GIT_COMMIT: ${{ github.sha }} + GIT_COMMIT: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} GIT_DATE: ${{ github.event.head_commit.timestamp }} - IMAGE_TAGS: ${{ github.sha }},latest + IMAGE_TAGS: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/celo')) && 'latest,' || '') }}${{ github.sha }} REGISTRY: us-west1-docker.pkg.dev REPOSITORY: blockchaintestsglobaltestnet/dev-images steps: