Skip to content

Bump step-security/harden-runner from 2.6.1 to 2.7.0 #335

Bump step-security/harden-runner from 2.6.1 to 2.7.0

Bump step-security/harden-runner from 2.6.1 to 2.7.0 #335

Workflow file for this run

name: Docker build
on:
workflow_dispatch:
push:
branches:
- "**"
tags:
- "v*"
pull_request:
branches:
- "main"
permissions:
contents: read
jobs:
docker:
name: Docker build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
security-events: write
pull-requests: write
outputs:
digest: ${{ steps.build-and-push.outputs.digest }}
steps:
- name: Harden runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
disable-sudo: true
egress-policy: audit
allowed-endpoints: >
api.dso.docker.com:443
api.github.com:443
api.scout.docker.com:443
auth.docker.io:443
cdn03.quay.io:443
files.pythonhosted.org:443
fulcio.sigstore.dev:443
ghcr.io:443
github.com:443
hub.docker.com:443
index.docker.io:443
nodejs.org:443
objects.githubusercontent.com:443
production.cloudflare.docker.com:443
pypi.org:443
quay.io:443
raw.githubusercontent.com:443
registry-1.docker.io:443
registry.npmjs.org:443
rekor.sigstore.dev:443
toolbox-data.anchore.io:443
tuf-repo-cdn.sigstore.dev:443
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
- name: Install Cosign
uses: sigstore/cosign-installer@9614fae9e5c5eddabb09f90a270fcb487c9f7149 # v3.3.0
- name: Docker meta
id: docker-meta
uses: docker/metadata-action@dbef88086f6cef02e264edb7dbf63250c17cef6c # v5.5.0
with:
images: |
jkreileder/cf-ips-to-hcloud-fw
quay.io/jkreileder/cf-ips-to-hcloud-fw
ghcr.io/jkreileder/cf-ips-to-hcloud-fw
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' && ',index' || '' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Login to DockerHub
if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork) && github.actor != 'dependabot[bot]' }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Quay
if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: build-and-push
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
context: .
platforms: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' && 'linux/amd64,linux/arm64' || '' }}
pull: true
push: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
load: ${{ github.event_name == 'pull_request' || github.actor == 'dependabot[bot]' }}
sbom: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' && 'generator=docker/scout-sbom-indexer' || '' }}
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
annotations: ${{ steps.docker-meta.outputs.annotations }}
- name: Sign the images with GitHub OIDC Token
if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --recursive --yes ${images}
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
TAGS: ${{ steps.docker-meta.outputs.tags }}
- name: Analyze for critical and high CVEs with Docker Scout
if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork) && github.actor != 'dependabot[bot]' }}
id: docker-scout-cves
continue-on-error: true
uses: docker/scout-action@42a6acc319ac229f86e12bfca3b83de09fb058be # v1.3.0
with:
command: cves${{ !startsWith(github.ref, 'refs/tags/') && ',recommendations,compare' || '' }}
image: jkreileder/cf-ips-to-hcloud-fw:${{ steps.docker-meta.outputs.version }}
sarif-file: sarif.output.json
organization: jkreileder
to: registry://jkreileder/cf-ips-to-hcloud-fw:1
- name: Upload Docker Scout scan result to GitHub Security tab
if: ${{ (github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork) && github.actor != 'dependabot[bot]' }}
continue-on-error: true
uses: github/codeql-action/upload-sarif@b7bf0a3ed3ecfa44160715d7c442788f65f0f923 # v3.23.2
with:
sarif_file: sarif.output.json
- name: Scan image with Grype
uses: anchore/scan-action@1c57367e29d11f99ae56571e49f95f1a1991945e # v3.6.3
id: grype-scan
continue-on-error: true
with:
image: jkreileder/cf-ips-to-hcloud-fw:${{ steps.docker-meta.outputs.version }}
only-fixed: true
add-cpes-if-none: true
- name: Upload Grype scan result to GitHub Security tab
uses: github/codeql-action/upload-sarif@b7bf0a3ed3ecfa44160715d7c442788f65f0f923 # v3.23.2
continue-on-error: true
with:
sarif_file: ${{ steps.grype-scan.outputs.sarif }}
provenance-docker:
name: Generate SLSA Provenance for DockerHub
if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
needs:
- docker
permissions:
actions: read
id-token: write
packages: write
# Can't pin with hash due to how this workflow works.
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
image: jkreileder/cf-ips-to-hcloud-fw
digest: ${{ needs.docker.outputs.digest }}
private-repository: true
secrets:
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}
provenance-quay:
name: Generate SLSA Provenance for Quay
if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
needs:
- docker
permissions:
actions: read
id-token: write
packages: write
# Can't pin with hash due to how this workflow works.
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
image: quay.io/jkreileder/cf-ips-to-hcloud-fw
digest: ${{ needs.docker.outputs.digest }}
private-repository: true
secrets:
registry-username: ${{ secrets.QUAY_USERNAME }}
registry-password: ${{ secrets.QUAY_TOKEN }}
provenance-ghcr:
name: Generate SLSA Provenance for GitHub Container Registry
if: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
needs:
- docker
permissions:
actions: read
id-token: write
packages: write
# Can't pin with hash due to how this workflow works.
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
image: ghcr.io/jkreileder/cf-ips-to-hcloud-fw
digest: ${{ needs.docker.outputs.digest }}
private-repository: true
secrets:
registry-username: ${{ github.repository_owner }}
registry-password: ${{ secrets.GITHUB_TOKEN }}