-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[FEATURE REQUEST] Modify sbom workflow to push to the repo #4621
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,26 @@ | ||
| name: SBOM | ||
|
|
||
| permissions: | ||
| contents: read | ||
| name: SBOM | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| sbom: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| # Checkout the full repository history (required to access origin/master) | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ssh-key: ${{ secrets.DEPLOYMENT_SSH_KEY }} | ||
|
|
||
| # Caches Gradle dependencies to avoid downloading them on every run | ||
| # Cache Gradle dependencies for faster builds | ||
| - name: Cache Gradle dependencies | ||
| uses: actions/cache@v4 | ||
| with: | ||
|
|
@@ -27,48 +32,55 @@ jobs: | |
| restore-keys: | | ||
| ${{ runner.os }}-gradle- | ||
|
|
||
| # Set up Java 17 for the Gradle build | ||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '17' | ||
| distribution: 'temurin' | ||
|
|
||
| - name: Install xsltproc | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y xsltproc | ||
|
|
||
| # Use --no-daemon to prevent Gradle from running in the background | ||
| # Generate the SBOM file using the CycloneDX plugin | ||
| - name: Generate SBOM (CycloneDX) | ||
| run: ./gradlew --no-daemon cyclonedxBom | ||
|
|
||
| - name: Convert SBOM to HTML | ||
| run: xsltproc sbom/cyclonedx-xml-to-html.xslt build/reports/bom.xml > sbom.html | ||
| # Move the generated SBOM to the repository root and rename it | ||
| - name: Move and rename SBOM to root | ||
| run: mv build/reports/bom.json ./sbom.json | ||
|
|
||
| # Create a specific artifact name using the branch name and timestamp | ||
| - name: Set artifact name | ||
| id: vars | ||
| # Remove non-deterministic fields to ensure meaningful diffs | ||
| - name: Clean serialNumber and timestamp in SBOM | ||
| run: | | ||
| BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}" | ||
| SAFE_BRANCH=$(echo "$BRANCH" | tr '/' '-' | tr '[:upper:]' '[:lower:]') | ||
| TIMESTAMP=$(date -u +"%Y%m%d-%H%M%S") | ||
| echo "artifact_name=sbom-${SAFE_BRANCH}-${TIMESTAMP}" >> $GITHUB_OUTPUT | ||
| sudo apt-get update && sudo apt-get install -y jq | ||
| jq 'del(.serialNumber, .timestamp)' sbom.json > sbom_clean.json && mv sbom_clean.json sbom.json | ||
|
|
||
| # Fetch the latest state of the master branch for comparison | ||
| - name: Fetch origin/master | ||
| run: git fetch origin master | ||
|
|
||
| - name: Rename SBOM XML and HTML files to match artifact name | ||
| # Extract and clean the SBOM from origin/master for comparison | ||
| - name: Extract clean SBOM from origin/master | ||
| run: | | ||
| mv sbom.html "${{ steps.vars.outputs.artifact_name }}.html" | ||
| mv build/reports/bom.xml "${{ steps.vars.outputs.artifact_name }}.xml" | ||
| mv build/reports/bom.json "${{ steps.vars.outputs.artifact_name }}.json" | ||
| # If sbom.json does not exist on master, create an empty JSON to prevent failure | ||
| git show origin/master:sbom.json > sbom_master.json || echo '{}' > sbom_master.json | ||
| jq 'del(.serialNumber, .timestamp)' sbom_master.json > sbom_master_clean.json | ||
|
|
||
| - name: ZIP all the files | ||
| # Compare the current SBOM with the cleaned version from master | ||
| - name: Compare current SBOM with master | ||
| id: diff | ||
| run: | | ||
| zip "${{ steps.vars.outputs.artifact_name }}.zip" \ | ||
| "${{ steps.vars.outputs.artifact_name }}.html" \ | ||
| "${{ steps.vars.outputs.artifact_name }}.xml" \ | ||
| "${{ steps.vars.outputs.artifact_name }}.json" | ||
| if diff -q sbom.json sbom_master_clean.json; then | ||
| echo "no_changes=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "no_changes=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Upload SBOM artifact | ||
| uses: actions/upload-artifact@v4 | ||
| # Commit and push the new SBOM only if it differs from master | ||
| - name: Commit files | ||
| if: steps.diff.outputs.no_changes == 'false' | ||
| uses: GuillaumeFalourd/[email protected] | ||
| with: | ||
| name: ${{ steps.vars.outputs.artifact_name }} | ||
| path: ${{ steps.vars.outputs.artifact_name }}.zip | ||
| email: [email protected] | ||
| name: ownClouders | ||
| commit_message: "docs: SBOM updated [skip ci]" | ||
| files: sbom.json | ||
| access_token: ${{ github.token }} | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| Enhancement: SBOM (Software Bill of Materials) | ||
|
|
||
| SBOM to be generated in every PR via GitHub Actions with the list of all dependencies used in the code. Tool cyclonedx builds it, artifact is exported to xml and finally converted to html with a xlst template. | ||
| SBOM to be generated in every PR via GitHub Actions with the list of all dependencies used in the code, powered by cyclonedx. Finally, it is pushed to the repo's root folder . | ||
|
|
||
| https://github.com/owncloud/android/issues/4598 | ||
| https://github.com/owncloud/android/pull/4599 | ||
|
|
||
| https://github.com/owncloud/android/pull/4621 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.