Skip to content

Prevent build-and-deploy workflow from running in forks - #11893

Open
MarkvanMents wants to merge 1 commit into
developmentfrom
no-fork-runs
Open

Prevent build-and-deploy workflow from running in forks#11893
MarkvanMents wants to merge 1 commit into
developmentfrom
no-fork-runs

Conversation

@MarkvanMents

Copy link
Copy Markdown
Collaborator

Issue

The build-and-deploy.yml workflow uses push and pull_request triggers scoped to the development and production branches. This caused the workflow to run in two unintended scenarios:

  • In forks: any fork that has a development or production branch triggers the workflow on pushes to those branches, consuming the fork's Actions minutes and failing when deployment secrets are absent.
  • On fork sync: when a fork is synced to the main repo and opens a PR, the pull_request trigger fires the workflow in the main repo against the fork's code.

Resolution

Added if: github.event.repository.fork == false to the build job. Because the deploy job depends on build via needs: build, it is automatically skipped whenever build is skipped. The workflow now only runs in the main repository, for both push and pull request events.

The push and pull_request triggers caused the workflow to run in forked
repositories, wasting Actions minutes and potentially failing on missing
secrets. Adding `if: github.event.repository.fork == false` to the build
job ensures the workflow only runs in the main repository.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants