Skip to content

Commit d4f4c45

Browse files
committed
fixup! wip: add reusable workflows
1 parent bc91dce commit d4f4c45

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

.github/workflows/reusable-review_apps_on_pr_change.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)