Skip to content

Commit f7dd58b

Browse files
authored
Merge pull request #28 from QuantStrategyLab/codex-fix-theme-momentum-snapshot
[codex] Tolerate protected-branch push rejection in theme snapshot
2 parents d4ddb98 + c2bc1ba commit f7dd58b

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

.github/workflows/theme_momentum_snapshot.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,20 @@ jobs:
9393
echo "No theme momentum changes to commit."
9494
else
9595
git commit -m "Update theme momentum snapshot [skip ci]"
96-
git push
96+
push_log="$(mktemp)"
97+
if git push 2>"${push_log}"; then
98+
rm -f "${push_log}"
99+
else
100+
if grep -Fq 'GH013: Repository rule violations found for refs/heads/main' "${push_log}" && grep -Eqi 'required status check' "${push_log}"; then
101+
echo "Push blocked by repository rules; keeping artifact-only output."
102+
cat "${push_log}"
103+
rm -f "${push_log}"
104+
else
105+
cat "${push_log}" >&2
106+
rm -f "${push_log}"
107+
exit 1
108+
fi
109+
fi
97110
fi
98111
- name: Upload theme momentum artifact
99112
uses: actions/upload-artifact@v7
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from __future__ import annotations
2+
3+
from pathlib import Path
4+
5+
6+
def test_theme_momentum_snapshot_workflow_tolerates_repo_rule_push_rejection() -> None:
7+
workflow = Path(".github/workflows/theme_momentum_snapshot.yml").read_text(encoding="utf-8")
8+
9+
assert "Push blocked by repository rules; keeping artifact-only output." in workflow
10+
assert "GH013: Repository rule violations found for refs/heads/main" in workflow
11+
assert "grep -Eqi 'required status check' \"${push_log}\"" in workflow
12+
assert "GH013|repository rule violations|required status check" not in workflow
13+
assert "git push 2>\"${push_log}\"" in workflow

0 commit comments

Comments
 (0)