Skip to content

Prevent actions from running in forks#3938

Merged
cheenamalhotra merged 2 commits intodotnet:mainfrom
ErikEJ:issue-3924
Feb 6, 2026
Merged

Prevent actions from running in forks#3938
cheenamalhotra merged 2 commits intodotnet:mainfrom
ErikEJ:issue-3924

Conversation

@ErikEJ
Copy link
Contributor

@ErikEJ ErikEJ commented Feb 5, 2026

Description

This change prevents GitHub actions from running in any fork

Issues

fixes #3924

@ErikEJ ErikEJ requested a review from a team as a code owner February 5, 2026 07:19
Copilot AI review requested due to automatic review settings February 5, 2026 07:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds fork prevention checks to GitHub Actions workflows to ensure they only run in the main repository, not in forked repositories. This addresses issue #3924 by preventing unnecessary workflow executions in forks.

Changes:

  • Added conditional checks to prevent workflows from running in forked repositories
  • Applied the fork check to both the stale issues/PRs cleanup workflow and the CodeQL security analysis workflow

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/stale.yml Added fork check to prevent stale issue/PR cleanup from running in forks
.github/workflows/codeql.yml Added fork check to prevent CodeQL security analysis from running in forks

jobs:
close-stale:
runs-on: ubuntu-latest
if: github.event.repository.fork != true
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The condition uses != true which will also evaluate to true when the value is null or undefined. For more explicit fork detection, use github.event.repository.fork == false or !github.event.repository.fork to ensure the check only passes when the repository is definitively not a fork.

Suggested change
if: github.event.repository.fork != true
if: github.event.repository.fork == false

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@mdaigle mdaigle left a comment

Choose a reason for hiding this comment

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

Thanks!

@cheenamalhotra cheenamalhotra merged commit db47359 into dotnet:main Feb 6, 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.

Avoid running GitHub actions on forks

3 participants