From 3e8fc3900039f3a550b0b012a3aa7c1a085f3f77 Mon Sep 17 00:00:00 2001 From: Sam Seed Date: Fri, 6 Oct 2023 14:00:14 +0100 Subject: [PATCH] Get sha of current commit + refactor --- .github/workflows/aws_deploy.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/aws_deploy.yml b/.github/workflows/aws_deploy.yml index f477d9ab1..a24abd285 100644 --- a/.github/workflows/aws_deploy.yml +++ b/.github/workflows/aws_deploy.yml @@ -101,22 +101,21 @@ jobs: with: ref: ${{ steps.latestrelease.outputs.releasetag }} - - name: Construct environment-dependent tag - id: tag + - name: Get tags + id: tags run: | - echo "::set-output name=tag::$(if [[ ${{ inputs.environment == 'production' }} ]]; then echo ${{ steps.latestrelease.outputs.releasetag }}; else echo ${{ steps.timestamp.outputs.timestamp }}; fi)" + echo "::set-output name=commit-tag::$(if [[ ${{ inputs.environment == 'production' }} ]]; then echo $(git log -1 '--format=format:%H'); else echo ${{ github.sha }}; fi)" + echo "::set-output name=additional-tag::$(if [[ ${{ inputs.environment == 'production' }} ]]; then echo ${{ steps.latestrelease.outputs.releasetag }}; else echo ${{ steps.timestamp.outputs.timestamp }}; fi)" - name: Add environment tag to existing image env: registry: ${{ steps.ecr-login.outputs.registry }} - commit_tag: ${{ github.sha }} - readable_tag: ${{ inputs.environment }}-${{ steps.tag.outputs.tag }} + commit_tag: ${{ steps.tags.outputs.commit-tag }} + readable_tag: ${{ inputs.environment }}-${{ steps.tags.outputs.additional-tag }} run: | - echo $commit_tag - echo $readable_tag manifest=$(aws ecr batch-get-image --repository-name $repository --image-ids imageTag=$commit_tag --output text --query images[].imageManifest) - echo $manifest aws ecr put-image --repository-name $repository --image-tag $readable_tag --image-manifest "$manifest" + echo "image=$registry/$repository:$readable_tag" >> $GITHUB_ENV # manifest=$(aws ecr batch-get-image --repository-name $repository --image-ids imageTag=$commit_tag --output text --query images[].imageManifest) # aws ecr put-image --repository-name $repository --image-tag $readable_tag --image-manifest "$manifest" # echo "image=$registry/$repository:$readable_tag" >> $GITHUB_ENV