Skip to content

Commit

Permalink
Only rebuild docker image when needed
Browse files Browse the repository at this point in the history
RISDEV-0000
  • Loading branch information
malte-laukoetter committed Jul 11, 2024
1 parent 1ab602e commit cfc24aa
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion .github/workflows/manual-branch-deploy-to-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,26 @@ jobs:
#############################################
# jobs dispatched to a separate workflow file
#############################################
check-if-image-exists:
runs-on: ubuntu-latest
outputs:
image-exists:
steps:
- name: Log into container registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check if image with commit sha already exists
run:
docker manifest inspect ghcr.io/${{ github.repository }}:${{ github.sha }} > /dev/null
test $? -eq 0 && echo "image-exists=true" >> "$GITHUB_OUTPUT" || echo "image-exists=false" >> "$GITHUB_OUTPUT"

create-docker-image-job:
needs:
- check-if-image-exists
if: ${{ needs.check-if-image-exists.outputs.image-exists == 'false' }}
permissions:
security-events: write # upload-sarif
packages: write
Expand Down Expand Up @@ -40,8 +58,11 @@ jobs:
deploy-staging-job:
needs:
- push-docker-image-job
- check-if-image-exists
if: |
always()
&& (needs.check-if-image-exists.outputs.image-exists == 'true' || needs.push-docker-image-job.result == 'success')
permissions:
id-token: write
uses: ./.github/workflows/deploy-staging-job.yml
secrets: inherit

0 comments on commit cfc24aa

Please sign in to comment.