-
Notifications
You must be signed in to change notification settings - Fork 469
73 lines (62 loc) · 2.44 KB
/
legacy-release_sbom-generator.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Generate SBOM for latest version of dotCMS and put into core-test-repo
on:
release:
types: [published]
workflow_dispatch:
inputs:
dotcms_version:
description: 'Enter the dotCMS version (vYY.MM.DD)'
required: true
default: ''
jobs:
scan:
runs-on: ubuntu-24.04
permissions:
contents: write # Ensure write access to contents
steps:
- name: Checkout core-test-results repository
uses: actions/checkout@v3
with:
repository: dotCMS/core-test-results
token: ${{ secrets.GITHUB_TOKEN }}
path: core-test-results
- name: Get dotCMS release version
id: get_version
run: |
if [ "${{ github.event_name }}" == "release" ]; then
# Extract the tag name from the release event context
latest_tag=${{ github.event.release.tag_name }}
else
# Use the input provided in manual run
latest_tag=${{ github.event.inputs.dotcms_version }}
fi
# Format the tag name if necessary
formatted_tag=$(echo "$latest_tag" | sed -e 's/^dotcms-cli-//' -e 's/^v//')
echo "Latest tag: $formatted_tag"
echo "DOTCMS_VERSION=$formatted_tag" >> $GITHUB_ENV
- name: Pull and run dotCMS Docker image
run: |
docker pull dotcms/dotcms:${{ env.DOTCMS_VERSION }}
docker run -d -p 8082:8082 dotcms/dotcms:${{ env.DOTCMS_VERSION }}
- name: Install pipx
run: |
pip install pipx
- name: Scan Docker Image with Syft
run: |
pipx run anchore_syft dotcms/dotcms:${{ env.DOTCMS_VERSION }} -o cyclonedx-xml > core-test-results/sbom/cyclonedx.json
- name: Rename SBOM file with dotCMS version
run: |
mkdir -p core-test-results/sbom
mv core-test-results/sbom/cyclonedx.json core-test-results/sbom/dotcms-${{ env.DOTCMS_VERSION }}.json
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
- name: Commit and push results to core-test-results repository
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}