File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,17 @@ upload_to_s3() {
169169 fi
170170}
171171
172+ # Global variable for temp directory (so cleanup can access it)
173+ temp_dir=" "
174+
175+ # Cleanup function
176+ cleanup () {
177+ if [[ -n " $temp_dir " && -d " $temp_dir " ]]; then
178+ log_info " Cleaning up temporary files"
179+ rm -rf " $temp_dir "
180+ fi
181+ }
182+
172183# Main function
173184main () {
174185 log_info " Starting ClickBOM GitHub Action for SBOM processing"
@@ -181,22 +192,16 @@ main() {
181192 local ref=" ${REF:- main} "
182193 local s3_key=" ${S3_KEY:- sbom.json} "
183194
195+ # Set up cleanup trap
196+ trap cleanup EXIT
197+
184198 # Temporary files
185- local temp_dir=" "
186199 if ! temp_dir=$( mktemp -d) ; then
187200 log_error " Failed to create temporary directory"
188201 exit 1
189202 fi
190203 local original_sbom=" $temp_dir /original_sbom.json"
191204 local cyclonedx_sbom=" $temp_dir /cyclonedx_sbom.json"
192- echo $temp_dir
193-
194- # Cleanup function
195- cleanup () {
196- log_info " Cleaning up temporary files"
197- rm -rf " $temp_dir "
198- }
199- trap cleanup EXIT
200205
201206 # Download SBOM
202207# download_sbom "$REPOSITORY" "$sbom_path" "$ref" "$original_sbom"
You can’t perform that action at this time.
0 commit comments