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,21 @@ 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
4247
4348 - name : Build container
44- run : docker build --tag "${{steps.generate_image_uri.outputs.URI}}" .
49+ run : |
50+ 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
51+ docker build --tag "${{steps.generate_image_uri.outputs.URI}}" --tag "${{steps.generate_image_uri.outputs.BASE_URI}}" .
4552
4653 - name : Push container
4754 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}}"
55+ docker push "${{steps.generate_image_uri.outputs.ECR_REPO }}" --all-tags
5256
5357 - name : Deploy review app via CodeBuild
5458 id : codebuild
You can’t perform that action at this time.
0 commit comments