Skip to content

Commit 9ce8f0f

Browse files
committed
ci(security): handle detect-secrets baseline churn in PR guard
1 parent e69bcff commit 9ce8f0f

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,24 @@ jobs:
241241
fi
242242
243243
printf 'Scanning %s files with detect-secrets-hook.\n' "${#changed_files[@]}"
244+
hook_log="$RUNNER_TEMP/detect-secrets-hook.log"
245+
set +e
244246
detect-secrets-hook \
245247
--baseline "$trusted_baseline" \
246-
"${changed_files[@]}"
248+
"${changed_files[@]}" \
249+
>"$hook_log" 2>&1
250+
hook_rc=$?
251+
set -e
252+
cat "$hook_log"
253+
254+
if [ "$hook_rc" -eq 0 ]; then
255+
exit 0
256+
fi
257+
if [ "$hook_rc" -eq 3 ] && ! grep -q "Potential secrets about to be committed" "$hook_log"; then
258+
echo "detect-secrets-hook updated baseline metadata only; continuing."
259+
exit 0
260+
fi
261+
exit "$hook_rc"
247262
248263
- name: Detect secrets in PR title/body
249264
if: github.event_name == 'pull_request'

0 commit comments

Comments
 (0)