Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run the program as action #4

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/selftest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SPDX-FileCopyrightText: 2024 DB Systel GmbH
#
# SPDX-License-Identifier: Apache-2.0

name: Selftest

on:
push:
branches:
- main
pull_request:

jobs:
# Generate SBOM using cdxgen, but with NPMJS package, not Docker container
sbom-gen:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install cdxgen
run: npm install -g @cyclonedx/cdxgen
- name: Generate CycloneDX SBOM with cdxgen
run: cdxgen -r . -o ${{ runner.temp }}/sbom-raw.json
- name: Store raw SBOM as artifact
uses: actions/upload-artifact@v4
with:
name: sbom-raw
path: ${{ runner.temp }}/sbom-raw.json

# Enrich the generated SBOM
sbom-enrich:
runs-on: ubuntu-22.04
needs: sbom-gen
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/poetrybuild
# Download raw SBOM
- uses: actions/download-artifact@v4
with:
name: sbom-raw
path: ${{ runner.temp }}
# Run compliance-assistant sbom-enrich
- name: Enrich SBOM
run: poetry run compliance-assistant sbom-enrich -f ${{ runner.temp }}/sbom-raw.json -o ${{ runner.temp }}/sbom-enriched.json
# Show and upload enriched SBOM
- name: Print SBOM content
run: cat ${{ runner.temp }}/sbom-enriched.json
- name: Store enriched SBOM as artifact
uses: actions/upload-artifact@v4
with:
name: sbom-enriched
path: ${{ runner.temp }}/sbom-enriched.json
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,61 @@ For each command, you can get detailed options, e.g. `compliance-assistant sbom-
* Extract certain data from an SBOM: `compliance-assistant sbom-parse -f /tmp/my-enriched-sbom.json -e purl,copyright,name`
* Gather ClearlyDefined licensing/copyright information for one package: `compliance-assistant clearlydefined -p pkg:pypi/inwx-dns-recordmaster@0.3.1`

### Run as GitHub workflow

You may also use GitHub workflows to generate an SBOM regularly, e.g. on each published release:

```yaml
name: Generate and enrich SBOM

on:
release:
types: [published]

jobs:
# Generate raw SBOM using cdxgen, but with NPMJS package, not Docker container
sbom-gen:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install cdxgen
run: npm install -g @cyclonedx/cdxgen
- name: Generate CycloneDX SBOM with cdxgen
run: cdxgen -r . -o ${{ runner.temp }}/sbom-raw.json
- name: Store raw SBOM as artifact
uses: actions/upload-artifact@v4
with:
name: sbom-raw
path: ${{ runner.temp }}/sbom-raw.json

# Enrich the generated SBOM
sbom-enrich:
runs-on: ubuntu-22.04
needs: sbom-gen
steps:
# Install compliance-assistant
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install compliance-assistant
run: pip install compliance-assistant
# Download raw SBOM
- uses: actions/download-artifact@v4
with:
name: sbom-raw
path: ${{ runner.temp }}
# Run compliance-assistant sbom-enrich
- name: Enrich SBOM
run: compliance-assistant sbom-enrich -f ${{ runner.temp }}/sbom-raw.json -o ${{ runner.temp }}/sbom-enriched.json
# Upload enriched SBOM as artifact
- name: Store enriched SBOM as artifact
uses: actions/upload-artifact@v4
with:
name: sbom-enriched
path: ${{ runner.temp }}/sbom-enriched.json
```


## Development and Contribution

Expand Down