-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
91 lines (79 loc) · 2.42 KB
/
action.yml
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: License Overview Generator
description: Downloads and runs the mvdkleijn/licenses tool on a given (CycloneDX) SBOM file.
branding:
icon: 'file-text'
color: 'red'
inputs:
sbom:
description: "The SBOM file to analyze."
required: true
type:
description: "The file type of the SBOM (xml or json). Defaults to xml."
required: false
default: "xml"
filename:
description: "The filename for the generated output. Defaults to 'licenses.md'."
required: false
default: "licenses.md"
template:
description: "Go template content for the report generation."
required: true
outputs:
output:
description: "The generated output file."
value: ${{ steps.run_licenses.outputs.output }}
runs:
using: "composite"
steps:
- name: Set up environment variables
id: setup
shell: bash
run: |
if [[ ${{ runner.os }} == 'Linux' ]]; then
OS="Linux"
elif [[ ${{ runner.os }} == 'macOS' ]]; then
OS="Darwin"
else
echo "Unsupported OS: $OS"
exit 1
fi
ARCH=$(uname -m)
if [[ "$ARCH" == "x86_64" ]]; then
ARCH="x86_64"
elif [[ "$ARCH" == "arm64" ]]; then
ARCH="arm64"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
echo "os_arch=${OS}_${ARCH}" >> $GITHUB_ENV
- name: Download binary
shell: bash
run: |
DOWNLOAD_URL="https://github.com/mvdkleijn/licenses/releases/download/v1.0.1/licenses_${{ env.os_arch }}.tar.gz"
curl -L -o licenses.tar.gz "$DOWNLOAD_URL"
- name: Extract binary
shell: bash
run: |
mkdir licenses_bin
tar -xzf licenses.tar.gz -C licenses_bin
- name: Create template file
shell: bash
run: |
echo "${{ inputs.template }}" > template.txt
- name: Run licenses tool
id: run_licenses
shell: bash
run: |
mkdir -p output
./licenses_bin/licenses -i "${{ inputs.sbom }}" -o "${{ inputs.filename }}" -f "${{ inputs.type }}" -t "template.txt"
- name: Upload output file
shell: bash
run: |
echo "output_path=output/${{ inputs.filename }}" >> $GITHUB_ENV
echo "output=output/${{ inputs.filename }}" >> $GITHUB_OUTPUT
- name: Save as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.filename }}
path: output/${{ inputs.filename }}