Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

generate sbom draft #15

generate sbom draft

generate sbom draft #15

Workflow file for this run

name: Publish Docker image
on:
push:
branches:
- main
jobs:
push_to_registry:
name: Push Docker image to Container Registry
runs-on: ubuntu-latest
permissions:
actions: read
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Container Registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ${{ vars.CONTAINER_REGISTRY }}
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Get Commit Hash
id: commit_hash
uses: prompt/actions-commit-hash@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ vars.DOCKER_USERNAME }}/${{ vars.DOCKER_REPO }}
tags: |
type=raw,value=${{ vars.APP_VERSION }}.${{github.run_number}}
type=raw,value=${{ steps.commit_hash.outputs.short }}
type=raw,value=latest
- name: Build and Push Docker Image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate Artifact Attestation
id: attest-artifacts
uses: actions/attest-build-provenance@v1
env:
IMAGE_NAME: ${{ vars.DOCKER_USERNAME }}/${{ vars.DOCKER_REPO }}
with:
subject-name: ${{ vars.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
- name: Generate SBOM
uses: anchore/sbom-action@v0
id: sbom
with:
image: ${{ vars.DOCKER_USERNAME }}/${{ vars.DOCKER_REPO }}:${{ vars.APP_VERSION }}.${{github.run_number}}
artifact-name: ${{ github.event.repository.name }}-${{github.run_number}}-sbom.spdx.json
# - name: Generate SBOM Attestation
# uses: actions/attest-sbom@v1
# env:
# IMAGE_NAME: ${{ vars.DOCKER_USERNAME }}/${{ vars.DOCKER_REPO }}
# with:
# subject-name: ${{ vars.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.push.outputs.digest }}
# sbom-path: 'sbom.json'
# push-to-registry: true