Try SBOM generation - git commit path fix #4
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: | |
push: | |
branches: [ main ] | |
pull_request: | |
jobs: | |
sbom: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.3 | |
extensions: dom, json, libxml | |
tools: composer:v2 | |
- name: Install Composer dependencies | |
run: composer install --no-interaction --no-progress | |
- name: Allow CycloneDX plugin | |
run: composer global config --no-plugins allow-plugins.cyclonedx/cyclonedx-php-composer true | |
- name: Install CycloneDX Composer plugin | |
run: composer global require cyclonedx/cyclonedx-php-composer | |
- name: Generate SBOM (CycloneDX XML) | |
run: composer CycloneDX:make-sbom --output-format=XML --output-file=sbom.xml | |
- name: Upload SBOM artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sbom | |
path: sbom.xml | |
- name: Commit and push SBOM file | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add sbom.xml | |
# Only commit if there are changes | |
git diff --cached --quiet sbom.xml || git commit -m "chore: update SBOM [skip ci]" | |
git push | |
env: | |
# Use the GitHub token for authentication | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload SBOM artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: sbom | |
path: sbom.xml |