Skip to content

Commit b541541

Browse files
committed
ci: update ShieldCI security scan workflow
1 parent e0d0e89 commit b541541

1 file changed

Lines changed: 13 additions & 21 deletions

File tree

.github/workflows/shieldci.yml

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
name: ShieldCI Security Scan
22

33
on:
4+
push:
5+
branches: [main, master]
46
pull_request:
57
branches: [main, master]
8+
workflow_dispatch:
69

710
jobs:
811
shieldci-scan:
@@ -24,35 +27,29 @@ jobs:
2427
- name: Check ShieldCI engine is available
2528
run: |
2629
if [ ! -f "$HOME/Desktop/ShieldCI/target/release/shield-ci" ]; then
27-
echo "ERROR: ShieldCI engine not found at ~/Desktop/ShieldCI/target/release/shield-ci"
28-
echo "Please build the engine first: cd ~/Desktop/ShieldCI && cargo build --release"
30+
echo "ERROR: ShieldCI engine not found"
2931
exit 1
3032
fi
3133
32-
- name: Copy shieldci.yml to engine tests directory
34+
- name: Copy shieldci.yml config
3335
run: |
3436
if [ -f "shieldci.yml" ]; then
3537
cp shieldci.yml "$HOME/Desktop/ShieldCI/tests/shieldci.yml"
36-
echo "Copied shieldci.yml config"
37-
else
38-
echo "No shieldci.yml found in repo root, engine will auto-detect"
3938
fi
4039
41-
- name: Copy target repo to engine tests directory
40+
- name: Copy target repo to engine
4241
run: |
4342
rm -rf "$HOME/Desktop/ShieldCI/tests/repo"
4443
cp -r "$GITHUB_WORKSPACE" "$HOME/Desktop/ShieldCI/tests/repo"
4544
4645
- name: Run ShieldCI engine
4746
id: scan
48-
working-directory: ${{ env.HOME }}/Desktop/ShieldCI/tests
4947
run: |
5048
START_TIME=$(date +%s)
5149
cd "$HOME/Desktop/ShieldCI/tests"
5250
"$HOME/Desktop/ShieldCI/target/release/shield-ci" 2>&1 | tee scan_output.log || true
5351
END_TIME=$(date +%s)
54-
DURATION=$((END_TIME - START_TIME))
55-
echo "duration=${DURATION}s" >> "$GITHUB_OUTPUT"
52+
echo "duration=$((END_TIME - START_TIME))s" >> "$GITHUB_OUTPUT"
5653
5754
- name: Push results to ShieldCI dashboard
5855
if: always()
@@ -65,29 +62,24 @@ jobs:
6562
SHIELDCI_COMMIT_MSG: ${{ steps.meta.outputs.commit_msg }}
6663
SHIELDCI_DURATION: ${{ steps.scan.outputs.duration }}
6764
SHIELDCI_TRIGGERED_BY: PR
68-
SHIELDCI_RESULTS_FILE: ${{ env.HOME }}/Desktop/ShieldCI/tests/shield_results.json
69-
run: |
70-
python3 "$HOME/Desktop/ShieldCI/push_results.py"
65+
SHIELDCI_RESULTS_FILE: $HOME/Desktop/ShieldCI/tests/shield_results.json
66+
run: python3 "$HOME/Desktop/ShieldCI/push_results.py"
7167

7268
- name: Post scan summary as PR comment
7369
if: always()
7470
uses: actions/github-script@v7
7571
with:
7672
script: |
7773
const fs = require('fs');
78-
const reportPath = `${process.env.HOME}/Desktop/ShieldCI/tests/SHIELD_REPORT.md`;
74+
const reportPath = process.env.HOME + '/Desktop/ShieldCI/tests/SHIELD_REPORT.md';
7975
let report = 'Scan completed but no report was generated.';
8076
try {
8177
report = fs.readFileSync(reportPath, 'utf8');
82-
if (report.length > 60000) {
83-
report = report.substring(0, 60000) + '\n\n... (truncated)';
84-
}
85-
} catch (e) {
86-
report = 'Could not read scan report.';
87-
}
78+
if (report.length > 60000) report = report.substring(0, 60000) + '\n\n... (truncated)';
79+
} catch (e) { report = 'Could not read scan report.'; }
8880
await github.rest.issues.createComment({
8981
issue_number: context.issue.number,
9082
owner: context.repo.owner,
9183
repo: context.repo.repo,
92-
body: `## 🛡️ ShieldCI Security Scan Results\n\n${report}`
84+
body: '## 🛡️ ShieldCI Security Scan Results\n\n' + report
9385
});

0 commit comments

Comments
 (0)