Update ci.yml #69
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: CI Pipeline | |
on: | |
push: | |
branches: ["main"] | |
tags: ["*"] | |
pull_request_target: | |
branches: ["main"] | |
env: | |
REGISTRY: docker.io | |
DOCKER_ORG: demonstrationorg | |
IMAGE_NAME: demonstrationorg/juvenile | |
SHA: ${{ github.event.pull_request.head.sha || github.event.after }} | |
DOCKERFILE_PATH: Dockerfile | |
COMPARE_TAG: latest | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
security-events: write | |
actions: read | |
contents: read | |
pull-requests: write | |
strategy: | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ env.SHA }} | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log into registry | |
uses: docker/login-action@v2 | |
with: | |
username: ${{secrets.DOCKER_USERNAME}} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.IMAGE_NAME }} | |
labels: | | |
org.opencontainers.image.revision=${{ env.SHA }} | |
com.docker.image.source.entrypoint=${{ env.DOCKERFILE_PATH }} | |
- name: Build and push Docker image on push | |
id: build-and-push | |
if: ${{ github.event_name != 'pull_request_target' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: false | |
push: true | |
platforms: ${{ matrix.platform }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
sbom: true | |
provenance: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Build and push Docker image on PR | |
id: build-and-push-pr | |
if: ${{ github.event_name == 'pull_request_target' }} | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
load: true | |
push: false | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: "linux/arm64" | |
sbom: false | |
provenance: false | |
github-token: ${{ secrets.GH_TOKEN }} # to be able to write the comment | |
- name: Docker Scout | |
id: docker-scout | |
uses: docker/scout-action@v1 | |
with: | |
command: cves,recommendations | |
only-fixed: true | |
exit-on: policy |