Skip to content

serverless-registry-proxy-build-push-ghcr #47

serverless-registry-proxy-build-push-ghcr

serverless-registry-proxy-build-push-ghcr #47

---
name: serverless-registry-proxy-build-push-ghcr
on:
push:
branches:
- 'master'
paths:
- 'serverless-registry-proxy/**'
- '.github/workflows/serverless-registry-proxy-build-push-ghcr.yml'
pull_request:
paths:
- 'serverless-registry-proxy/**'
- '.github/workflows/serverless-registry-proxy-build-push-ghcr.yml'
workflow_dispatch:
repository_dispatch:
schedule:
- cron: '0 12 15 * *'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/gcr-proxy
IMAGE_TAG: latest
IMAGE_PLATFORMS: linux/amd64,linux/arm64
REPO_CONTEXT: ./serverless-registry-proxy
REPO_CONTAINERFILE: ./serverless-registry-proxy/Dockerfile
jobs:
build:
runs-on: ubuntu-latest
permissions:
actions: write
packages: write
contents: read
security-events: write
steps:
-
name: Cancel previous run in progress
id: cancel-previous-runs
uses: styfle/cancel-workflow-action@0.11.0
with:
ignore_sha: true
all_but_latest: true
access_token: ${{ secrets.GITHUB_TOKEN }}
-
name: Checkout
id: repo-checkout
uses: actions/checkout@v4
with:
repository: ahmetb/serverless-registry-proxy
submodules: recursive
path: ./serverless-registry-proxy
-
name: Set up QEMU
id: setup-qemu
uses: docker/setup-qemu-action@v3
-
name: Set up Buildx
id: setup-buildx
uses: docker/setup-buildx-action@v3
-
name: Log in to registry
id: registry-login
uses: docker/#-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build image
id: build-image
uses: docker/build-push-action@v5
with:
context: ${{ env.REPO_CONTEXT }}
file: ${{ env.REPO_CONTAINERFILE }}
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
platforms: ${{ env.IMAGE_PLATFORMS }}
-
name: Run Trivy vulnerability scanner
id: trivy-scan
uses: aquasecurity/trivy-action@master
env:
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
with:
scan-type: 'image'
image-ref: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
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
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'