Docker Scan #152
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
# yaml-language-server: $schema=https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json | |
name: Docker Scan | |
on: | |
schedule: | |
# Every sunday at 02:00 | |
- cron: 0 2 * * 0 | |
workflow_dispatch: ~ | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
env: | |
GKE_CLUSTER: api-platform-demo | |
GCE_ZONE: europe-west1-c | |
jobs: | |
scan: | |
name: Docker Vulnerability Scan | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
image: | |
- php | |
- pwa | |
fail-fast: false | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Auth gcloud | |
id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
token_format: access_token | |
credentials_json: ${{ secrets.GKE_SA_KEY }} | |
- | |
name: Login to GAR | |
uses: docker/login-action@v3 | |
with: | |
registry: europe-west1-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.auth.outputs.access_token }} | |
- | |
name: Setup gcloud | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.gke-project }} | |
- | |
name: Configure gcloud | |
run: | | |
gcloud components install gke-gcloud-auth-plugin | |
gcloud --quiet auth configure-docker | |
gcloud container clusters get-credentials ${{ env.GKE_CLUSTER }} --zone ${{ env.GCE_ZONE }} | |
- | |
name: Pull Docker Image | |
run: docker pull europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/${{ matrix.image }}:latest | |
- | |
name: Cache Trivy | |
uses: actions/cache@v4 | |
with: | |
path: .trivy | |
key: ${{ runner.os }}-trivy-${{ github.run_id }} | |
restore-keys: | | |
${{ runner.os }}-trivy- | |
- | |
name: Run Trivy Vulnerability Scanner | |
uses: aquasecurity/trivy-action@master | |
with: | |
image-ref: 'europe-west1-docker.pkg.dev/${{ secrets.GKE_PROJECT }}/${{ secrets.GKE_PROJECT }}/${{ matrix.image }}:latest' | |
exit-code: '1' | |
ignore-unfixed: true | |
vuln-type: 'os' | |
cache-dir: .trivy |