Skip to content

Commit

Permalink
deploy-production.yml: don't rebuild image for workflow_dispatch
Browse files Browse the repository at this point in the history
grab image digest from the tagged image on ECR
  • Loading branch information
digorgonzola committed Dec 14, 2023
1 parent e0831bf commit 4fbc46e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
environment: production
outputs:
image_digest: ${{ steps.build_and_push.outputs.digest }}
image_digest: ${{ steps.build_and_push.outputs.digest || steps.get_digest_from_tagged_image.outputs.image_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -45,6 +45,7 @@ jobs:
echo "image_tag=${tag//\v/}" >> $GITHUB_OUTPUT
- name: Build and Push Docker Image
if: ${{ github.event != "workflow_dispatch" }}
id: build_and_push
uses: docker/build-push-action@v5
with:
Expand All @@ -54,6 +55,17 @@ jobs:
push: true
tags: ${{ vars.ECR_REGISTRY }}/${{ vars.ECR_REPOSITORY }}:${{ steps.set_image_tag.outputs.image_tag }}

# For manually triggered runs, grab the image digest from the already built image
- name: Get Digest from Tagged Image
if: ${{ github.event == "workflow_dispatch" }}
id: get_digest_from_tagged_image
run: |
image_digest=$(aws ecr describe-images
--repository-name ${{ vars.ECR_REPOSITORY }} \
--image-ids imageTag=${{ steps.set_image_tag.outputs.image_tag }} \
| jq -r '.imageDetails[].imageDigest')
echo "image_tag=$image_tag" >> $GITHUB_OUTPUT
production_deploy:
runs-on: ubuntu-latest
environment: production
Expand Down

0 comments on commit 4fbc46e

Please sign in to comment.