vagrant-libvirt-build-push-ghcr #73
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: vagrant-libvirt-build-push-ghcr | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
workflow_dispatch: | |
repository_dispatch: | |
schedule: | |
- cron: '0 12 15 * *' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/vagrant-libvirt | |
IMAGE_TAG: latest | |
IMAGE_ARCH: amd64 | |
REPO_CONTEXT: . | |
REPO_CONTAINERFILE: ./Dockerfile | |
jobs: | |
buildah: | |
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/[email protected] | |
with: | |
ignore_sha: true | |
all_but_latest: true | |
access_token: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Checkout | |
id: repo-checkout | |
uses: actions/checkout@v3 | |
- | |
name: Set up QEMU | |
id: setup-qemu | |
uses: docker/setup-qemu-action@v2 | |
- | |
name: Log in to registry | |
id: registry-login | |
uses: redhat-actions/podman-login@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Build | |
id: build-image | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
image: ${{ env.IMAGE_NAME }} | |
tags: ${{ env.IMAGE_TAG }} | |
context: ${{ env.REPO_CONTEXT }} | |
containerfiles: ${{ env.REPO_CONTAINERFILE }} | |
archs: ${{ env.IMAGE_ARCH }} | |
build-args: | | |
DEFAULT_OTHER_PLUGINS=vagrant-mutate,vagrant-reload,vagrant-scp,vagrant-sshfs,vagrant-vbguest | |
- | |
name: Run Trivy vulnerability scanner | |
id: trivy-scan | |
uses: aquasecurity/trivy-action@master | |
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' | |
- | |
name: Push | |
id: push-to-ghcr | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
image: ${{ steps.build-image.outputs.image }} | |
tags: ${{ steps.build-image.outputs.tags }} | |
registry: ${{ env.REGISTRY }} |