Skip to content

Commit ded38bb

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

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

.github/workflows/reusable-review_apps_on_pr_change.yml

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

0 commit comments

Comments
 (0)