Skip to content

Commit

Permalink
#29944 SBOM generation encapsulate into an action.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcolina committed Oct 10, 2024
1 parent 1731aec commit aebcc91
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions .github/actions/legacy-release/sbom-generator/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@ inputs:
dotcms_version:
description: 'The dotCMS version (vYY.MM.DD)'
required: true
dotcms_package:
description: 'The dotCMS product (core, cli, etc.)'
required: true
github_token:
description: 'GitHub token for pushing changes'
required: true
outputs:
sbom-artifact:
description: 'SBOM artifact'
value: ${{ steps.sbom-artifact.outputs.artifact }}

runs:
using: "composite"
steps:
- name: Checkout core-test-results repository
uses: actions/checkout@v4
with:
repository: dotCMS/core-test-results
repository: dotCMS/core
token: ${{ inputs.github_token }}
path: core-test-results
path: core

- name: Set dotCMS version
shell: bash
Expand All @@ -37,26 +44,24 @@ runs:
- name: Scan Docker Image with Syft
shell: bash
run: |
pipx run anchore_syft dotcms/dotcms:${{ env.DOTCMS_VERSION }} -o cyclonedx-xml > core-test-results/sbom/cyclonedx.json
pipx run anchore_syft dotcms/dotcms:${{ env.DOTCMS_VERSION }} -o cyclonedx-json > core/sbom-cyclonedx.json
- name: Rename SBOM file with dotCMS version
shell: bash
run: |
mkdir -p core-test-results/sbom
mv core-test-results/sbom/cyclonedx.json core-test-results/sbom/dotcms-${{ env.DOTCMS_VERSION }}.json
mv core/sbom-cyclonedx.json core/sbom-dotcms-${{ inputs.dotcms_package }}-${{ env.DOTCMS_VERSION }}.json
- name: Configure Git
shell: bash
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
- name: Upload SBOM to GitHub
uses: actions/upload-artifact@v4
with:
name: sbom-dotcms-${{ inputs.dotcms_package }}-${{ env.DOTCMS_VERSION }}
path: core/sbom-dotcms-${{ inputs.dotcms_package }}-${{ env.DOTCMS_VERSION }}.json

- name: Commit and push results to core-test-results repository
- name: Set SBOM artifact
shell: bash
run: |
cd core-test-results
git add sbom/dotcms-${{ env.DOTCMS_VERSION }}.json
git commit -m "Add SBOM for dotCMS version ${{ env.DOTCMS_VERSION }}" || echo "No changes to commit"
git push origin main
id: sbom-artifact
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
PACKAGE: ${{ inputs.dotcms_package }}
VERSION: ${{ env.DOTCMS_VERSION }}
run: |
echo "artifact=sbom-dotcms-${PACKAGE}-${VERSION}" >> $GITHUB_OUTPUT

0 comments on commit aebcc91

Please sign in to comment.