Skip to content

ci: trigger publish only after Build and Test succeeds on master - #2288

Merged
dfahlander merged 1 commit into
masterfrom
liz/publish-after-tests
Mar 31, 2026
Merged

ci: trigger publish only after Build and Test succeeds on master#2288
dfahlander merged 1 commit into
masterfrom
liz/publish-after-tests

Conversation

@liz709

@liz709 liz709 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Problem

Publish workflow ran in parallel with tests — a broken build could get published to npm.

Fix

Switch from push trigger to workflow_run trigger, waiting for Build and Test to complete successfully before publishing.

on:
  workflow_run:
    workflows: ["Build and Test"]
    types: [completed]
    branches: [master]

Added job-level condition:

if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'

Behavior

  • Push to master → tests run → if ✅ → publish runs
  • Push to master → tests fail → publish never runs
  • Fix commit pushed → tests pass → publish runs and picks up any previously-bumped-but-unpublished versions (skip logic is version-based)
  • Manual workflow_dispatch (PR prereleases) → unaffected, always runs

Summary by CodeRabbit

  • Chores
    • Enhanced release automation to publish dev builds only after builds complete successfully and tests pass, ensuring higher quality releases.

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.
@coderabbitai

coderabbitai Bot commented Mar 31, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The .github/workflows/publish.yml workflow trigger was changed from automatic push-based execution to a conditional workflow_run that executes after the "Build and Test" workflow succeeds on the master branch, with added job-level guards for manual (workflow_dispatch) or successful completions.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow Configuration
.github/workflows/publish.yml
Changed publish workflow trigger from on: push to on: workflow_run (triggered when "Build and Test" completes on master). Added job-level conditional guard to run publish only on workflow_dispatch or when triggering workflow concluded with success. Updated inline comments to reflect new control flow.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 A workflow once triggered by every push,
Now waits for Build and Test's blessed hush,
Conditional guards keep watch with care,
Dev publishes thrive in the master's air! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: modifying the CI workflow to trigger publishing only after the Build and Test workflow succeeds on master, which directly addresses the problem of preventing broken builds from being published.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch liz/publish-after-tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🔴 Critical

Bug: workflow_run events will have empty MODE.

The condition on line 121 checks for push events, but the push trigger was removed. Now the workflow only triggers via workflow_run or workflow_dispatch. For workflow_run events:

  • github.event_name is "workflow_run", not "push"
  • inputs.mode is empty (inputs are only populated for workflow_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

📥 Commits

Reviewing files that changed from the base of the PR and between ab489de and 23d8211.

📒 Files selected for processing (1)
  • .github/workflows/publish.yml

@dfahlander
dfahlander merged commit 9ee82c8 into master Mar 31, 2026
7 checks passed
@dfahlander
dfahlander deleted the liz/publish-after-tests branch March 31, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants