File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,17 +38,23 @@ jobs:
3838 HEAD_SHA : ${{ github.event.pull_request.head.sha }}
3939 run : |
4040 echo "ECR_REPO=${ECR_REPO}" >> "$GITHUB_OUTPUT"
41- echo "URI=${ECR_REPO}:pr-${PR_NUMBER}-${HEAD_SHA}-$(date +%s)" >> "$GITHUB_OUTPUT"
41+ BASE_URI="${ECR_REPO}:pr-${PR_NUMBER}"
42+ echo "BASE_URI=${BASE_URI}" >> "$GITHUB_OUTPUT"
43+ echo "URI=${BASE_URI}-${HEAD_SHA}-$(date +%s)" >> "$GITHUB_OUTPUT"
44+
45+ - name : Log in to Amazon ECR
46+ uses : aws-actions/amazon-ecr-login@5a88a04c91d5c6f97aae0d9be790e64d9b1d47b7 # v1.7.1
47+ with :
48+ registries : ${{ steps.generate_image_uri.outputs.ECR_REPO }}
4249
4350 - name : Build container
44- run : docker build --tag "${{steps.generate_image_uri.outputs.URI}}" .
51+ run : |
52+ docker pull "${{ steps.generate_image_uri.outputs.BASE_URI }}" || true # Pull the previous image to warm the cache, but don't fail if it doesn't exist
53+ docker build --tag "${{steps.generate_image_uri.outputs.URI}}" --tag "${{steps.generate_image_uri.outputs.BASE_URI}}" .
4554
4655 - name : Push container
4756 run : |
48- aws ecr get-login-password --region ${{ inputs.aws-region }} \
49- | docker login --username AWS --password-stdin "${{ steps.generate_image_uri.outputs.ECR_REPO }}"
50-
51- docker push "${{steps.generate_image_uri.outputs.URI}}"
57+ docker push "${{steps.generate_image_uri.outputs.ECR_REPO }}" --all-tags
5258
5359 - name : Deploy review app via CodeBuild
5460 id : codebuild
You can’t perform that action at this time.
0 commit comments