ci: trigger publish only after Build and Test succeeds on master - #2288
Conversation
Instead of triggering on push directly, use workflow_run to wait for 'Build and Test' to complete successfully. This prevents publishing broken builds. If tests fail and are then fixed, publish will run on the fix commit and still pick up any previously unbumped-but-unpublished versions (since skip logic is version-based, not diff-based). Manual workflow_dispatch (PR prereleases) is unaffected.
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/publish.yml (1)
119-125:⚠️ Potential issue | 🔴 CriticalBug:
workflow_runevents will have empty MODE.The condition on line 121 checks for
pushevents, but thepushtrigger was removed. Now the workflow only triggers viaworkflow_runorworkflow_dispatch. Forworkflow_runevents:
github.event_nameis"workflow_run", not"push"inputs.modeis empty (inputs are only populated forworkflow_dispatch)This causes MODE to be set to an empty string, breaking the publish logic for dev builds.
🐛 Proposed fix to handle workflow_run events
# Determine mode: push to master = dev, workflow_dispatch = use input - if [ "${{ github.event_name }}" = "push" ]; then + if [ "${{ github.event_name }}" = "workflow_run" ]; then MODE="dev" else MODE="${{ inputs.mode }}" fi🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/publish.yml around lines 119 - 125, The MODE determination currently only checks for "push" and ends up empty for "workflow_run" events; update the conditional in the run block that sets MODE so that "workflow_run" also sets MODE="dev" (or treat any non-workflow_dispatch as dev), and when using "${{ inputs.mode }}" ensure you fall back to "dev" if inputs.mode is empty; look for the MODE variable assignment and the github.event_name check in that run block and change the logic to set MODE="dev" for workflow_run and default to "dev" when inputs.mode is unset.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In @.github/workflows/publish.yml:
- Around line 119-125: The MODE determination currently only checks for "push"
and ends up empty for "workflow_run" events; update the conditional in the run
block that sets MODE so that "workflow_run" also sets MODE="dev" (or treat any
non-workflow_dispatch as dev), and when using "${{ inputs.mode }}" ensure you
fall back to "dev" if inputs.mode is empty; look for the MODE variable
assignment and the github.event_name check in that run block and change the
logic to set MODE="dev" for workflow_run and default to "dev" when inputs.mode
is unset.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 45be4a91-ae67-42b7-b38b-9d5e923c2631
📒 Files selected for processing (1)
.github/workflows/publish.yml
Problem
Publish workflow ran in parallel with tests — a broken build could get published to npm.
Fix
Switch from
pushtrigger toworkflow_runtrigger, waiting for Build and Test to complete successfully before publishing.Added job-level condition:
Behavior
workflow_dispatch(PR prereleases) → unaffected, always runsSummary by CodeRabbit