From 5758364c82f7fc72b256f9a8cfc89dc550d7dd66 Mon Sep 17 00:00:00 2001 From: Azeem Shaikh Date: Fri, 6 May 2022 13:38:19 -0700 Subject: [PATCH] Fix bug in Scorecard tag Docker image creation (#1890) Co-authored-by: Azeem Shaikh --- cloudbuild/scorecard-tag.yaml | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/cloudbuild/scorecard-tag.yaml b/cloudbuild/scorecard-tag.yaml index 92181eeb046..863d00ef122 100644 --- a/cloudbuild/scorecard-tag.yaml +++ b/cloudbuild/scorecard-tag.yaml @@ -13,12 +13,28 @@ # limitations under the License. steps: -- id: 'Get Git history' - name: 'gcr.io/cloud-builders/git' - args: ['fetch', '--unshallow', '--tags', 'origin', '$COMMIT_SHA'] -- name: 'gcr.io/cloud-builders/docker' - args: ['build', '.', - '-t', 'gcr.io/openssf/scorecard:stable', - '-t', 'gcr.io/openssf/scorecard:$TAG_NAME', - '-f', 'Dockerfile'] + - id: Get Git history + name: gcr.io/cloud-builders/git + args: + - fetch + - '--unshallow' + - '--tags' + - origin + - $COMMIT_SHA + - id: Get tag commit + name: gcr.io/cloud-builders/git + entrypoint: bash + args: + - '-c' + - >- + git rev-list -n 1 tags/$TAG_NAME > /workspace/commit-sha.txt + - id: Push docker tag + name: gcr.io/cloud-builders/docker + entrypoint: bash + args: + - '-c' + - >- + docker pull gcr.io/openssf/scorecard:$(cat /workspace/commit-sha.txt) && + docker tag gcr.io/openssf/scorecard:$(cat /workspace/commit-sha.txt) gcr.io/openssf/scorecard:$TAG_NAME && + docker push gcr.io/openssf/scorecard:$TAG_NAME images: ['gcr.io/openssf/scorecard']