1- name : SBOM
2-
3- permissions :
4- contents : read
1+ name : SBOM
52
63on :
74 workflow_dispatch :
8- pull_request :
5+ push :
6+ branches :
7+ - feature/*
8+ - fix/*
9+ - improvement/*
10+ - release/*
11+ - technical/*
12+
13+ permissions :
14+ contents : write
915
1016jobs :
1117 sbom :
1218 runs-on : ubuntu-latest
13-
19+
1420 steps :
1521 - name : Checkout repository
1622 uses : actions/checkout@v4
23+ with :
24+ persist-credentials : false
1725
18- # Caches Gradle dependencies to avoid downloading them on every run
1926 - name : Cache Gradle dependencies
2027 uses : actions/cache@v4
2128 with :
@@ -33,42 +40,22 @@ jobs:
3340 java-version : ' 17'
3441 distribution : ' temurin'
3542
36- - name : Install xsltproc
37- run : |
38- sudo apt-get update
39- sudo apt-get install -y xsltproc
40-
41- # Use --no-daemon to prevent Gradle from running in the background
4243 - name : Generate SBOM (CycloneDX)
4344 run : ./gradlew --no-daemon cyclonedxBom
4445
45- - name : Convert SBOM to HTML
46- run : xsltproc sbom/cyclonedx-xml-to-html.xslt build/reports/bom.xml > sbom.html
47-
48- # Create a specific artifact name using the branch name and timestamp
49- - name : Set artifact name
50- id : vars
51- run : |
52- BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
53- SAFE_BRANCH=$(echo "$BRANCH" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
54- TIMESTAMP=$(date -u +"%Y%m%d-%H%M%S")
55- echo "artifact_name=sbom-${SAFE_BRANCH}-${TIMESTAMP}" >> $GITHUB_OUTPUT
56-
57- - name : Rename SBOM XML and HTML files to match artifact name
58- run : |
59- mv sbom.html "${{ steps.vars.outputs.artifact_name }}.html"
60- mv build/reports/bom.xml "${{ steps.vars.outputs.artifact_name }}.xml"
61- mv build/reports/bom.json "${{ steps.vars.outputs.artifact_name }}.json"
46+ - name : Move and rename SBOM to root
47+ run : mv build/reports/bom.json ./sbom.json
6248
63- - name : ZIP all the files
49+ - name : Clean serialNumber and timestamp in SBOM
6450 run : |
65- zip "${{ steps.vars.outputs.artifact_name }}.zip" \
66- "${{ steps.vars.outputs.artifact_name }}.html" \
67- "${{ steps.vars.outputs.artifact_name }}.xml" \
68- "${{ steps.vars.outputs.artifact_name }}.json"
51+ sudo apt-get update && sudo apt-get install -y jq
52+ jq 'del(.serialNumber, .timestamp)' sbom.json > sbom_clean.json && mv sbom_clean.json sbom.json
6953
70- - name : Upload SBOM artifact
71- uses : actions/upload-artifact@v4
54+ - name : Commit files
55+ uses : GuillaumeFalourd/git-commit-push@v1.3
7256 with :
73- name : ${{ steps.vars.outputs.artifact_name }}
74- path : ${{ steps.vars.outputs.artifact_name }}.zip
57+ email : devops@owncloud.com
58+ name : ownClouders
59+ commit_message : " docs: SBOM updated"
60+ files : sbom.json
61+ access_token : ${{ github.token }}
0 commit comments