Skip to content

Commit

Permalink
IT-391: Rebuild container when daily Trivy scan fails
Browse files Browse the repository at this point in the history
  • Loading branch information
brucehoff committed Oct 30, 2024
1 parent 134d261 commit 491d981
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ on:
IMAGE_NAME:
required: true
type: string
EXIT_CODE:
EXIT_CODE: # # return code for failed scan. 0 means OK. Non-zero will fail the build when there are findings.
required: false
type: number
default: 0

env:
sarif_file_name: trivy-results.sarif
Expand Down Expand Up @@ -78,4 +79,7 @@ jobs:
with:
sarif_file: ${{ env.sarif_file_name }}
wait-for-processing: true

outputs:
trivy_conclusion: steps.trivy.outputs.conclusion
...
16 changes: 15 additions & 1 deletion .github/workflows/trivy_periodic_image_scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
id: image_name
uses: vishalmamidi/lowercase-action@v1
with:
string: ghcr.io/${{ github.repository }}:main
string: ghcr.io/${{ github.repository }}:main # if rebuilding for a new tag does not also rebuild 'main', then change this to scan the latest tag
outputs:
lowercase: ${{ steps.image_name.outputs.lowercase }}

Expand All @@ -30,4 +30,18 @@ jobs:
with:
SOURCE_TYPE: image
IMAGE_NAME: ${{ needs.lower-case.outputs.lowercase }}

# If scan failed, rebuild the image
update-image:
needs: periodic-scan
runs-on: ubuntu-latest
if: ${{needs.periodic-scan.outputs.trivy_conclusion == 'failure' }}
# tag the repo to trigger a new build
steps:
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

...

0 comments on commit 491d981

Please sign in to comment.