-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-codeql-cron-monthly.sh
More file actions
executable file
·51 lines (44 loc) · 1.2 KB
/
Copy pathfix-codeql-cron-monthly.sh
File metadata and controls
executable file
·51 lines (44 loc) · 1.2 KB
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
#!/bin/bash
# SPDX-License-Identifier: MPL-2.0
#
# fix-codeql-cron-monthly.sh — convert codeql.yml cron to canonical monthly
#
# Driven by hypatia WF025 (codeql-cron-monthly recipe). Per standards#286
# (Option B 2026-05-30 estate decision): CodeQL schedule monthly canonical
# `0 6 1 * *`. PR-trigger runs unchanged.
#
# Handles both #288-shape (weekly `0 6 * * 1` → monthly) and #324-shape
# (any non-canonical cron → monthly).
#
# Idempotent: skips files already on canonical monthly.
set -euo pipefail
REPO_PATH="$1"
FINDING_FILE="${2:-}"
cd "$REPO_PATH"
F=".github/workflows/codeql.yml"
if [[ ! -f "$F" ]]; then
echo "fix-codeql-cron-monthly: no $F in $REPO_PATH"
exit 0
fi
if grep -qF "cron: '0 6 1 * *'" "$F"; then
echo "fix-codeql-cron-monthly: already canonical monthly: $F"
exit 0
fi
python3 - <<PY
import re, sys
p = "$F"
content = open(p).read()
new, n = re.subn(
r"(^[ \t]*-[ \t]*cron:[ \t]*)'[^']+'(.*)",
r"\1'0 6 1 * *' # monthly 1st 06:00 UTC",
content,
count=1,
flags=re.MULTILINE,
)
if n == 0:
print("fix-codeql-cron-monthly: no cron line found in", p)
sys.exit(0)
open(p, "w").write(new)
print(f"fix-codeql-cron-monthly: 1 cron line replaced in", p)
PY
exit 0