name: SBOM upload to Complair
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
sbom:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Generate an SBOM (swap this for the generator your stack uses)
- name: Generate CycloneDX SBOM
run: |
npx --yes @cyclonedx/cdxgen -o sbom.cdx.json
- name: Upload to Complair
env:
COMPLAIR_SBOM_TOKEN: ${{ secrets.COMPLAIR_SBOM_TOKEN }}
RELEASE_VERSION: ${{ github.ref_name }}
run: |
curl --fail-with-body -sS -X POST \
"https://complair.eu/api/v1/sboms?format=cyclonedx_1_5&release_version=${RELEASE_VERSION}" \
-H "Authorization: Bearer $COMPLAIR_SBOM_TOKEN" \
-H "Content-Type: application/octet-stream" \
-H "Idempotency-Key: ${{ github.run_id }}-${{ github.run_attempt }}" \
--data-binary @sbom.cdx.json
A GitLab CI snippet is on the roadmap. The endpoint is identical, so a minimal pipeline job is straightforward to adapt:
sbom:
stage: release
rules:
- if: $CI_COMMIT_TAG
script:
- npx --yes @cyclonedx/cdxgen -o sbom.cdx.json
- |
curl --fail-with-body -sS -X POST \
"https://complair.eu/api/v1/sboms?format=cyclonedx_1_5&release_version=${CI_COMMIT_TAG}" \
-H "Authorization: Bearer $COMPLAIR_SBOM_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @sbom.cdx.json
Add COMPLAIR_SBOM_TOKEN as a masked variable in the project settings before enabling the job.