diff brief and true #63
Workflow file for this run
This file contains hidden or 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
| name: Generate SBOM | |
| on: | |
| workflow_dispatch: | |
| push: | |
| # branches: | |
| # - 'master' | |
| # - 'releases/**' | |
| # - 'CXX**' | |
| jobs: | |
| configure-and-scan: | |
| strategy: | |
| fail-fast: false | |
| permissions: | |
| id-token: write # Required to request a json web token (JWT) for keyless authentication with Endor Labs | |
| contents: write # Required for commit | |
| pull-requests: write # Required for PR | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| # - name: Configure CMake and fetch dependency sources | |
| # env: | |
| # BUILD_TYPE: Release | |
| # BUILD: ${{github.workspace}}/build | |
| # CXX_STANDARD: 17 | |
| # working-directory: ${{env.BUILD}} | |
| # run: cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_STANDARD=${{env.CXX_STANDARD}} -DENABLE_TESTS=ON | |
| # - name: Install endorctl and Scan with Endor Labs | |
| # uses: endorlabs/github-action@519df81de5f68536c84ae05ebb2986d0bb1d19fc # v1.1.8 | |
| # with: | |
| # additional_args: "--languages=c --exclude-path=\"build/CMakeFiles/**\"" | |
| # log_level: info | |
| # log_verbose: false | |
| # namespace: mongodb.${{github.repository_owner}} | |
| # pr: false | |
| # scan_dependencies: true | |
| # tags: github_action | |
| # env: | |
| # ENDOR_SCAN_EMBEDDINGS: true | |
| - name: Install endorctl | |
| uses: endorlabs/github-action/setup@519df81de5f68536c84ae05ebb2986d0bb1d19fc # v1.1.8 | |
| with: | |
| namespace: mongodb.${{github.repository_owner}} | |
| enable_github_action_token: true | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | |
| with: | |
| python-version: '3.10' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 # v7.1.4 | |
| with: | |
| python-version: "3.10" | |
| activate-environment: true | |
| enable-cache: true | |
| - name: Install dependencies | |
| run: uv sync --group generate_sbom | |
| - name: Save existing SBOM for comparison | |
| run: | | |
| # Strip out nondeterministic SBOM fields and save to temp file | |
| jq 'del(.version, .metadata.timestamp, .metadata.tools.services[].version)' sbom.json > ${{runner.temp}}/sbom.existing.cdx.json | |
| - name: generate_sbom.py | |
| run: | | |
| uv run etc/sbom/generate_sbom.py --enable-github-action-token --target=branch --sbom-metadata=etc/sbom/metadata.cdx.json --save-warnings=${{runner.temp}}/warnings.txt | |
| - name: Check for SBOM changes | |
| id: sbom_diff | |
| run: | | |
| # Strip out nondeterministic SBOM fields and save to temp file | |
| jq 'del(.version, .metadata.timestamp, .metadata.tools.services[].version)' sbom.json > ${{runner.temp}}/sbom.generated.cdx.json | |
| RESULT=$(diff --brief ${{runner.temp}}/sbom.existing.cdx.json ${{runner.temp}}/sbom.generated.cdx.json || true) | |
| # Set the output variable | |
| echo "::set-output name=result::$RESULT" | |
| - name: Generate pull request content and notice, if SBOM has changed | |
| if: ${{ steps.sbom_diff.outputs.result }} | |
| run: | | |
| printf "SBOM updated after commit ${{ github.sha }}.\n\n" | cat - ${{runner.temp}}/warnings.txt > ${{runner.temp}}/pr_body.txt | |
| echo "::notice SBOM has changed" | |
| - name: Open Pull Request, if SBOM has changed | |
| if: ${{ steps.sbom_diff.outputs.result }} | |
| uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.9 | |
| with: | |
| add-paths: sbom.json | |
| body-path: ${{runner.temp}}/pr_body.txt | |
| branch: cxx-sbom-update | |
| commit-message: Update SBOM file(s) | |
| delete-branch: true | |
| title: CXX Update SBOM action |