From e35cff12362c4be95ee8fad03288edeeb7956f73 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Sat, 4 Jul 2026 22:03:44 +0800 Subject: [PATCH 1/2] fix: tolerate protected snapshot push rejection Co-Authored-By: Codex --- .github/workflows/theme_momentum_snapshot.yml | 15 ++++++++++++++- tests/test_theme_momentum_snapshot_workflow.py | 11 +++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/test_theme_momentum_snapshot_workflow.py diff --git a/.github/workflows/theme_momentum_snapshot.yml b/.github/workflows/theme_momentum_snapshot.yml index c832f27..a1558f4 100644 --- a/.github/workflows/theme_momentum_snapshot.yml +++ b/.github/workflows/theme_momentum_snapshot.yml @@ -93,7 +93,20 @@ jobs: echo "No theme momentum changes to commit." else git commit -m "Update theme momentum snapshot [skip ci]" - git push + push_log="$(mktemp)" + if git push 2>"${push_log}"; then + rm -f "${push_log}" + else + if grep -Eq 'GH013|repository rule violations|required status check' "${push_log}"; then + echo "Push blocked by repository rules; keeping artifact-only output." + cat "${push_log}" + rm -f "${push_log}" + else + cat "${push_log}" >&2 + rm -f "${push_log}" + exit 1 + fi + fi fi - name: Upload theme momentum artifact uses: actions/upload-artifact@v7 diff --git a/tests/test_theme_momentum_snapshot_workflow.py b/tests/test_theme_momentum_snapshot_workflow.py new file mode 100644 index 0000000..2e0a965 --- /dev/null +++ b/tests/test_theme_momentum_snapshot_workflow.py @@ -0,0 +1,11 @@ +from __future__ import annotations + +from pathlib import Path + + +def test_theme_momentum_snapshot_workflow_tolerates_repo_rule_push_rejection() -> None: + workflow = Path(".github/workflows/theme_momentum_snapshot.yml").read_text(encoding="utf-8") + + assert "Push blocked by repository rules; keeping artifact-only output." in workflow + assert "GH013|repository rule violations|required status check" in workflow + assert "git push 2>\"${push_log}\"" in workflow From c2bc1bafadacb7709713f731fc5a861a2b74b714 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Fri, 10 Jul 2026 23:06:12 +0800 Subject: [PATCH 2/2] fix(ci): narrow protected push rejection handling Co-Authored-By: Codex --- .github/workflows/theme_momentum_snapshot.yml | 2 +- tests/test_theme_momentum_snapshot_workflow.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/theme_momentum_snapshot.yml b/.github/workflows/theme_momentum_snapshot.yml index a1558f4..6f819af 100644 --- a/.github/workflows/theme_momentum_snapshot.yml +++ b/.github/workflows/theme_momentum_snapshot.yml @@ -97,7 +97,7 @@ jobs: if git push 2>"${push_log}"; then rm -f "${push_log}" else - if grep -Eq 'GH013|repository rule violations|required status check' "${push_log}"; then + if grep -Fq 'GH013: Repository rule violations found for refs/heads/main' "${push_log}" && grep -Eqi 'required status check' "${push_log}"; then echo "Push blocked by repository rules; keeping artifact-only output." cat "${push_log}" rm -f "${push_log}" diff --git a/tests/test_theme_momentum_snapshot_workflow.py b/tests/test_theme_momentum_snapshot_workflow.py index 2e0a965..80a6f38 100644 --- a/tests/test_theme_momentum_snapshot_workflow.py +++ b/tests/test_theme_momentum_snapshot_workflow.py @@ -7,5 +7,7 @@ def test_theme_momentum_snapshot_workflow_tolerates_repo_rule_push_rejection() - workflow = Path(".github/workflows/theme_momentum_snapshot.yml").read_text(encoding="utf-8") assert "Push blocked by repository rules; keeping artifact-only output." in workflow - assert "GH013|repository rule violations|required status check" in workflow + assert "GH013: Repository rule violations found for refs/heads/main" in workflow + assert "grep -Eqi 'required status check' \"${push_log}\"" in workflow + assert "GH013|repository rule violations|required status check" not in workflow assert "git push 2>\"${push_log}\"" in workflow