From d3f378bb0fd5978874e8263942da68228d0c806f Mon Sep 17 00:00:00 2001 From: chainchad <96362174+chainchad@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:05:10 -0400 Subject: [PATCH] Use correct git commit sha as build metadata from manual workflow dispatches (#11068) --- .github/actions/build-sign-publish-chainlink/action.yml | 8 +++++++- .github/workflows/build-publish-develop.yml | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/actions/build-sign-publish-chainlink/action.yml b/.github/actions/build-sign-publish-chainlink/action.yml index feef0e78d3b..853702045e8 100644 --- a/.github/actions/build-sign-publish-chainlink/action.yml +++ b/.github/actions/build-sign-publish-chainlink/action.yml @@ -10,6 +10,7 @@ inputs: required: false dockerfile: + description: Path to the Dockerfile (relative to the repo root) default: core/chainlink.Dockerfile required: false ecr-hostname: @@ -23,6 +24,11 @@ inputs: default: chainlink/chainlink required: false ecr-tag-suffix: + description: Docker image tag suffix + required: false + git-commit-sha: + description: Git commit SHA used as metadata when building the application (appears in logs) + default: ${{ github.sha }} required: false aws-role-to-assume: description: The AWS role to assume as the CD user, if any. Used in configuring the docker/login-action @@ -74,7 +80,7 @@ runs: ) SHARED_BUILD_ARGS=$(cat << EOF - COMMIT_SHA=${{ github.sha }} + COMMIT_SHA=${{ inputs.git-commit-sha }} EOF ) diff --git a/.github/workflows/build-publish-develop.yml b/.github/workflows/build-publish-develop.yml index 8dcef84e551..cba8edba3e2 100644 --- a/.github/workflows/build-publish-develop.yml +++ b/.github/workflows/build-publish-develop.yml @@ -34,6 +34,13 @@ jobs: uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: ref: ${{ env.GIT_REF }} + # When this is ran from manual workflow_dispatch, the github.sha may be + # different than the checked out commit sha. The core build uses this + # commit sha as build metadata, so we need to make sure it's correct. + - name: Get checked out git ref + if: github.event.inputs.git_ref + id: git-ref + run: echo "checked-out=$(git rev-parse HEAD)" | tee -a "${GITHUB_OUTPUT}" - name: Build, sign and publish chainlink image uses: ./.github/actions/build-sign-publish-chainlink with: @@ -45,6 +52,7 @@ jobs: ecr-image-name: chainlink ecr-tag-suffix: ${{ matrix.image.tag-suffix }} dockerfile: ${{ matrix.image.dockerfile }} + git-commit-sha: ${{ steps.git-ref.outputs.checked-out || github.sha }} - name: Collect Metrics if: always() id: collect-gha-metrics