fix: trigger-podcast uses publish branch article + auto-merge sync PRs (#537)
* Fix podcast trigger to use publish branch article (#535) trigger-podcast.yml: fall back to checking out the article from origin/publish when it is not yet present on main, so podcast generation can run before the sync PR is merged. sync-publish-to-main.yml: enable auto-merge on the sync PR so it squashes into main as soon as required checks pass, and tolerate the PR already being merged via auto-merge in the explicit merge step. Fixes #535 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Address review: guard empty PR_NUMBER, log auto-merge failure Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Juan Manuel Servera committed
Jun 22, 2026 at 12:05 UTC
17a1521fefa9a7421e16660dfabf5aba403ccc8d
2 files changed
+19
-3
.github/workflows/sync-publish-to-main.yml
+13
-1
@@ -114,6 +114,15 @@ jobs:
114
PR_NUMBER=$(gh pr list --head "$SYNC_BRANCH" --base main --json number --jq '.[0].number')
115
fi
116
117
+ if [ -z "$PR_NUMBER" ]; then
118
+ echo "::error::Could not determine PR number for sync branch $SYNC_BRANCH"
119
+ exit 1
120
+ fi
121
+
122
+ # Enable auto-merge so the sync PR squashes into main as soon as its
123
+ # required checks pass, without waiting for manual intervention.
124
+ gh pr merge "$PR_NUMBER" --auto --squash || echo "::notice::Auto-merge request failed for PR #${PR_NUMBER} — will attempt explicit merge later"
125
+
126
HEAD_SHA=$(git rev-parse HEAD)
127
CHECK_COUNT=0
128
for _ in $(seq 1 30); do
@@ -131,4 +140,7 @@ jobs:
140
fi
141
142
gh pr checks "$PR_NUMBER" --watch --fail-fast
134
- gh pr merge "$PR_NUMBER" --squash --match-head-commit "$HEAD_SHA"
143
+ # Auto-merge may have already squashed the PR once checks passed; if the
144
+ # explicit merge fails, confirm the PR did in fact merge before succeeding.
145
+ gh pr merge "$PR_NUMBER" --squash --match-head-commit "$HEAD_SHA" || \
146
+ gh pr view "$PR_NUMBER" --json state --jq '.state' | grep -qx MERGED
.github/workflows/trigger-podcast.yml
+6
-2
@@ -112,8 +112,12 @@ jobs:
112
exit 1
113
fi
114
if [ ! -f "$ARTICLE_PATH" ]; then
115
- echo "::error::Article '$ARTICLE_PATH' does not exist in the repository."
116
- exit 1
115
+ # Article may already be published on the publish branch but not yet
116
+ # merged into main via the sync PR. Fall back to the publish branch.
117
+ git checkout origin/publish -- "$ARTICLE_PATH" 2>/dev/null || {
118
+ echo "::error::Article '$ARTICLE_PATH' does not exist on main or the publish branch."
119
+ exit 1
120
+ }
121
fi
122
if [ ! -f "$MANIFEST_FILE" ]; then
123
echo "::error::Manifest file not found: $MANIFEST_FILE"