Updates cosign #180
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
# This workflow will build and push a signed Docker image | |
name: Build and sign image | |
on: | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build_and_sign_image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
id-token: write | |
security-events: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Clear Sigstore cache | |
run: rm -rf ~/.sigstore | |
- uses: anchore/sbom-action@v0 | |
with: | |
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
output-file: ./nginx-loadbalancer-kubernetes-${{env.GITHUB_REF_NAME}}.spdx.json | |
registry-username: ${{ github.actor }} | |
registry-password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install cosign | |
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da #v3.7.0 | |
with: | |
cosign-release: 'v2.4.1' | |
- name: Log into registry ${{ env.REGISTRY }} for ${{ github.actor }} | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@9dc751fe249ad99385a2583ee0d084c400eee04e | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build Docker Image | |
id: docker-build-and-push | |
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{github.run_number}} | |
- name: Sign the published Docker images | |
env: | |
COSIGN_EXPERIMENTAL: "true" | |
# This step uses the identity token to provision an ephemeral certificate | |
# against the sigstore community Fulcio instance. | |
run: cosign sign "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.docker-build-and-push.outputs.digest }}" | |
# NOTE: This runs statically against the latest tag in Docker Hub which was not produced by this workflow | |
# This should be updated once this workflow is fully implemented | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@91713af97dc80187565512baba96e4364e983601 # 0.16.0 | |
continue-on-error: true | |
with: | |
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
format: 'sarif' | |
output: 'trivy-results-${{ inputs.image }}.sarif' | |
ignore-unfixed: 'true' | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@012739e5082ff0c22ca6d6ab32e07c36df03c4a4 # v2.2.11 | |
continue-on-error: true | |
with: | |
sarif_file: 'trivy-results-${{ inputs.image }}.sarif' | |
sha: ${{ github.sha }} | |
ref: ${{ github.ref }} | |
- name: Generate Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: | | |
trivy-results-${{ inputs.image }}.sarif | |
./nginx-loadbalancer-kubernetes-${{env.GITHUB_REF_NAME}}.spdx.json | |
body: | | |
# Release ${{env.GITHUB_REF_NAME}} | |
## Changelog | |
${{ steps.meta.outputs.changelog }} | |
generateReleaseNotes: true | |
makeLatest: false | |
name: "${{env.GITHUB_REF_NAME}}" |