Skip to content

[FEATURE]:Prevent workflows from running in fork repositories #14671

@niushuai1991

Description

@niushuai1991

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem:
When users fork the opencode repository and sync branches from upstream (e.g., git pull upstream dev), all GitHub Actions workflows are triggered in their fork repositories. This causes several issues:

  1. Resource waste - CI/CD minutes are consumed running jobs that serve no purpose in forks
  2. Unnecessary notifications - Fork maintainers receive workflow run notifications and emails
  3. Jobs stuck in queued state - Some jobs get stuck indefinitely when they reference secrets that don't exist in forks (e.g., docs-locale-sync, daily-issues-recap)
  4. Noise and confusion - Seeing queued/failed jobs creates confusion about whether something is broken
    Current behavior:
  • All 27 workflows execute when syncing branches in any fork
  • Jobs like publish, deploy, docs-locale-sync, stats, daily-recap run unnecessarily
  • These jobs either fail (missing secrets) or queue indefinitely
    Proposed solution:
    Add if: github.repository == 'anomalyco/opencode' condition to all workflow jobs that are only meaningful for the official repository. This includes:
  • Jobs that modify repository state: publish, deploy, sync-zed-extension, nix-hashes (update-hashes job)
  • Jobs that generate/modify content: docs-locale-sync, generate, docs-update
  • Jobs that send notifications: notify-discord, daily-issues-recap, daily-pr-recap
  • Maintenance/janitorial tasks: stats, close-stale-prs, stale-issues, compliance-close, etc.
    Important: Validation jobs (test, typecheck, nix-eval, review, pr-standards, etc.) should retain the guard because:
  • When fork users submit PRs, these jobs run in the upstream repository context (anomalyco/opencode), so the condition passes
  • When pushing directly to fork branches, they're skipped (saves resources)
  • This maintains full CI for legitimate contributions
    Benefits:
    ✅ Reduces CI resource consumption across all forks
    ✅ Eliminates noise and confusion for fork maintainers
    ✅ Prevents jobs from getting stuck in queued state
    ✅ Maintains full CI/CD for fork PRs (they still run in upstream context)
    ✅ Allows fork users to freely sync branches without triggering workflows
    ✅ No impact on the official repository's workflow behavior
    Implementation:
  • Add if: github.repository == 'anomalyco/opencode' to jobs in all 27 workflow files
  • For jobs with existing conditions, combine with && operator
  • Example:
    jobs:
    some-job:
    if: github.repository == 'anomalyco/opencode'

Validation:
This change has been tested in my fork (niushuai1991/opencode):

  • Pushing to fork shows "No jobs were run" instead of executing workflows
  • Previously stuck docs-locale-sync job now properly skips execution
  • Validation jobs will still run for PRs (since they execute in upstream context)

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions