generated from 18F/open-source-policy
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (66 loc) · 2.6 KB
/
pull-scan-push-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
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:v1.24.05
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/[email protected]
with:
scan-type: 'image'
image-ref: ${{ matrix.image.name }}
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
exit-code: 1
scanners: 'vuln'
# Upload results to GH Code Scanning even if the scan exited with 1 due to CRITICAL/HIGH findings
# Just don't carry on and push the image to GHCR!
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
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 }}