-
Notifications
You must be signed in to change notification settings - Fork 24
/
entrypoint.sh
34 lines (26 loc) · 1.04 KB
/
entrypoint.sh
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
#!/bin/bash
output_file=./output.log
eval "arr=(${ADDITIONAL_PARAMS})"
/app/bin/cx scan create --project-name "${PROJECT_NAME}" -s "." --branch "${BRANCH#refs/heads/}" --scan-info-format json --agent "Github Action" "${arr[@]}" | tee -i $output_file
exitCode=${PIPESTATUS[0]}
scanId=(`grep -E '"(ID)":"((\\"|[^"])*)"' $output_file | cut -d',' -f1 | cut -d':' -f2 | tr -d '"'`)
echo "cxcli=$(cat $output_file | tr -d '\r\n')" >> $GITHUB_OUTPUT
if [ -n "$scanId" ] && [ -n "${PR_NUMBER}" ]; then
echo "Creating PR decoration for scan ID:" $scanId
/app/bin/cx utils pr github --scan-id "${scanId}" --namespace "${NAMESPACE}" --repo-name "${REPO_NAME}" --pr-number "${PR_NUMBER}" --token "${GITHUB_TOKEN}"
else
echo "PR decoration not created."
fi
if [ -n "$scanId" ]; then
/app/bin/cx results show --scan-id "${scanId}" --report-format markdown
cat ./cx_result.md >$GITHUB_STEP_SUMMARY
rm ./cx_result.md
echo "cxScanID=$scanId" >> $GITHUB_OUTPUT
fi
if [ $exitCode -eq 0 ]
then
echo "Scan completed"
else
echo "Scan failed"
exit $exitCode
fi