Pull images, scan, push to GHCR #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Pull images, scan, push to GHCR | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 5 * * 0' | |
jobs: | |
pull-and-scan: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
security-events: write | |
env: | |
GH_REPO: gsa-tts/cg-supabase | |
strategy: | |
fail-fast: false | |
matrix: | |
image: | |
- name: ghcr.io/supabase/postgres-meta:v0.81.1 | |
short-name: meta | |
- name: postgrest/postgrest:latest | |
short-name: rest | |
- name: ghcr.io/supabase/storage-api:v1.3.1 | |
short-name: storage | |
- name: ghcr.io/supabase/studio:20240527-f428ce5 | |
short-name: studio | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Pull Docker Image | |
run: docker pull ${{ matrix.image.name }} | |
- name: Scan Image | |
uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe | |
with: | |
scan-type: 'image' | |
image-ref: ${{ matrix.image.name }} | |
format: 'template' | |
template: '@/contrib/sarif.tpl' | |
output: 'trivy-results.sarif' | |
severity: 'CRITICAL,HIGH' | |
exit-code: 1 | |
scanners: 'vuln' | |
# Upload results to GH Code Scanning even if there are CRITICAL/HIGH findings | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v2 | |
if: ${{ !cancelled() }} | |
with: | |
sarif_file: 'trivy-results.sarif' | |
- name: Tag Image | |
run: | | |
date=$(date +%Y%m%d) | |
docker tag ${{ matrix.image.name }} ghcr.io/${{ env.GH_REPO }}/${{ matrix.image.short-name }}:latest | |
docker tag ${{ matrix.image.name }} ghcr.io/${{ env.GH_REPO }}/${{ matrix.image.short-name }}:scanned | |
docker tag ${{ matrix.image.name }} ghcr.io/${{ env.GH_REPO }}/${{ matrix.image.short-name }}:$date | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push Image | |
run: docker push --all-tags ghcr.io/${{ env.GH_REPO }}/${{ matrix.image.short-name }} | |