gimp-build-push-ghcr #179
This file contains hidden or 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: gimp-build-push-ghcr | |
on: | |
push: | |
branches: | |
- 'master' | |
paths: | |
- 'gimp/**' | |
- '.github/workflows/gimp-build-push-ghcr.yml' | |
pull_request: | |
paths: | |
- 'gimp/**' | |
- '.github/workflows/gimp-build-push-ghcr.yml' | |
workflow_dispatch: | |
repository_dispatch: | |
schedule: | |
- cron: '0 12 15 * *' | |
jobs: | |
docker: | |
runs-on: ${{ matrix.os }} | |
permissions: | |
actions: write | |
packages: write | |
contents: read | |
security-events: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-24.04 | |
arch: amd64 | |
platform: linux/amd64 | |
- os: ubuntu-24.04-arm | |
arch: arm64 | |
platform: linux/arm64 | |
steps: | |
- | |
name: Cancel previous run in progress | |
uses: styfle/cancel-workflow-action@0.12.1 | |
with: | |
ignore_sha: true | |
all_but_latest: true | |
access_token: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Generate arch tag suffix | |
shell: bash | |
run: echo "archtag=$([[ "${{ matrix.platform }}" == 'linux/amd64' ]] && echo '' || ( echo -n '-' ; echo "${{ matrix.platform }}" | cut -d '/' -f 2) )" >> $GITHUB_OUTPUT | |
id: arch_tag_suffix | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver-opts: | | |
image=moby/buildkit:master | |
- | |
name: Log in to registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./gimp | |
file: ./gimp/Dockerfile | |
build-args: | | |
TARGETPLATFORM=${{ matrix.platform }} | |
push: true | |
provenance: false | |
platforms: ${{ matrix.platform }} | |
tags: ghcr.io/${{ github.repository_owner }}/gimp:latest${{ steps.arch_tag_suffix.outputs.archtag }} | |
- | |
name: Run Trivy vulnerability scanner | |
if: ${{ matrix.platform == 'linux/amd64' }} | |
id: trivy-scan | |
uses: aquasecurity/trivy-action@0.29.0 | |
env: | |
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db | |
with: | |
scan-type: 'image' | |
scanners: 'vuln' | |
image-ref: ghcr.io/${{ github.repository_owner }}/gimp:latest${{ steps.arch_tag_suffix.outputs.archtag }} | |
format: 'sarif' | |
output: 'trivy-results.sarif' | |
severity: 'HIGH,CRITICAL' | |
vuln-type: 'os,library' | |
hide-progress: true | |
ignore-unfixed: true | |
exit-code: '0' | |
- | |
name: Upload Trivy scan results to GitHub Security tab | |
if: ${{ matrix.platform == 'linux/amd64' }} | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: 'trivy-results.sarif' |