Skip to content

Fix: deploy workflow could publish a non-main branch to production - #97

Merged
nabobalis merged 1 commit into
numfocus:mainfrom
Aditya30ag:fix/deploy-gate-arbitrary-branch
Aug 26, 2026
Merged

Fix: deploy workflow could publish a non-main branch to production#97
nabobalis merged 1 commit into
numfocus:mainfrom
Aditya30ag:fix/deploy-gate-arbitrary-branch

Conversation

@Aditya30ag

Copy link
Copy Markdown
Contributor

Fixes #96

Problem

The deploy job's if condition let a manual workflow_dispatch run bypass the main-branch check entirely:

- github.event_name != 'pull_request' && (
- github.ref_name == 'main' ||
- github.event_name == 'workflow_dispatch'
- )
+ github.event_name != 'pull_request' &&
+ github.ref_name == 'main'

Because of the original ||, dispatching the workflow on any branch satisfied the condition and this job deploys with contents: write + force_orphan: true (which wipes gh-pages history), so an accidental manual run from the wrong branch would overwrite the live site with unreviewed content and destroy the previous deployment history.

Change

Require ref_name == 'main' unconditionally, for both push and workflow_dispatch triggers. push behavior is unchanged. Manual redeploys via workflow_dispatch still work exactly as before, as long as they're triggered on main they just can no longer target other branches.

Type of change

  • Bug fix (workflow/CI, non-breaking for normal use)

@nabobalis
nabobalis merged commit 5867d8c into numfocus:main Aug 26, 2026
3 checks passed
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.

deploy workflow can publish an arbitrary branch to production

2 participants