fix(blog): guard PR step on publish outputs#692
Merged
Conversation
GITHUB_TOKEN lacks admin permissions to merge PRs that require approving reviews. Use GH_PAT (already available as repo secret) for both checkout and PR merge. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The "Create and merge PR" step was running even when the article was already published, causing failures with empty branch/slug vars. Now gates on publish step outputs being set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR fixes the blog publish workflow so that triggering it against an already-published article no longer causes the "Create and merge PR" step to fail with empty variables. Key changes:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([workflow_dispatch]) --> B[Checkout @ develop\ntoken: GH_PAT]
B --> C{Resolve Article\nstep: resolve}
C -->|slug input provided| D[Find article by slug]
C -->|no slug input| E[Find oldest draft]
D -->|not found| F([exit 1 — error])
E -->|none found| G([exit 0 — nothing to do])
D -->|found| H[Set resolve.outputs.article]
E -->|found| H
H --> I{Publish Article\nstep: publish\nif: resolve.outputs.article != ''}
I -->|status: draft| J[Update frontmatter\nCreate branch & push\nSet slug/branch/title outputs]
I -->|status: published| K([exit 0 — already published\nno outputs set])
I -->|no status field| L([exit 1 — warning])
J --> M{Create and merge PR\nif: publish.outputs.slug != ''}
K -.->|slug is empty| N([Step SKIPPED ✓])
M -->|slug set| O[gh pr create\ngh pr merge --admin\nGH_TOKEN: GH_PAT]
O --> P([Done — article live])
style K fill:#f9c,stroke:#c66
style N fill:#cfc,stroke:#6c6
style F fill:#f9c,stroke:#c66
style L fill:#f9c,stroke:#c66
style P fill:#cfc,stroke:#6c6
Prompt To Fix All With AIThis is a comment left during a code review.
Path: .github/workflows/blog-publish.yml
Line: 107
Comment:
**`--admin` bypasses branch protections**
`gh pr merge --admin` merges the PR as a repository admin, bypassing all required status checks and branch protection rules on `develop`. With `GITHUB_TOKEN` this would have silently failed (no admin rights), but with a properly-scoped `GH_PAT` this will now succeed unconditionally — even if CI checks haven't passed.
This is likely intentional for a fully-automated publish pipeline, but it's worth confirming and ideally documenting in a comment above this line. If the `develop` branch later gets required checks added, they will be bypassed silently here.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: e8281de |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prevents failure when article is already published.