build(deps): bump ubuntu from jammy-20230816 to jammy-20240212 #74
Workflow file for this run
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: Build and Publish | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
branches: | |
- master | |
workflow_dispatch: | |
branches: | |
- master | |
jobs: | |
build-test-image: | |
name: Build Image for Testing & Scanning | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- name: Checkout git repo | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to ghcr.io registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push to GHCR | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/sameersbn/apt-cacher-ng:${{ github.run_id }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/amd64 | |
test-integration: | |
name: Integration tests in Docker Compose | |
needs: [build-test-image] | |
runs-on: ubuntu-latest | |
permissions: | |
packages: read | |
steps: | |
- name: Checkout git repo | |
uses: actions/checkout@v3 | |
- name: Login to ghcr.io registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
scan-image: | |
name: Scan Image with Trivy | |
needs: [build-test-image] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: read | |
security-events: write | |
steps: | |
- name: Checkout git repo | |
uses: actions/checkout@v3 | |
- name: Login to ghcr.io registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Pull image to scan | |
run: docker pull ghcr.io/sameersbn/apt-cacher-ng:"$GITHUB_RUN_ID" | |
- name: Run Trivy for HIGH,CRITICAL CVEs and report (blocking) | |
uses: aquasecurity/trivy-action@master | |
with: | |
image-ref: ghcr.io/sameersbn/apt-cacher-ng:${{ github.run_id }} | |
exit-code: 0 | |
ignore-unfixed: true | |
vuln-type: 'os,library' | |
severity: 'HIGH,CRITICAL' | |
format: 'sarif' | |
output: 'results.sarif' | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
sarif_file: results.sarif | |
category: results | |
build-and-push-docker-image: | |
name: Build and Push Docker Image | |
needs: [test-integration, scan-image] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
sameersbn/apt-cacher-ng | |
quay.io/sameersbn/apt-cacher-ng | |
ghcr.io/sameersbn/apt-cacher-ng | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
latest | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to Github Packages | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Login to Quay.io | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_TOKEN }} | |
- name: Build image and push to container registries | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7 | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} |