---
title: "Required checks that need secrets on fork pull requests | Proofline"
description: "Fork pull requests run without repository secrets, so a required check that needs one fails for outside contributors or is skipped untested."
url: https://proofline.sh/learn/required-checks-on-fork-pull-requests/
---

[Learning center](/learn/)

# Required checks that need secrets on fork pull requests

Fork pull requests run without repository secrets, so a required check that needs one fails for outside contributors or is skipped untested. Require only checks that can run without secrets, run the secret-dependent tests where secrets exist, and keep pull\_request\_target away from pull request code.

Code review The Proofline team November 23, 2026 4 min read

## What a fork pull request gets

For pull requests from forks, GitHub sends the `pull_request` event to the base repository, and the run is restricted: "With the exception of `GITHUB_TOKEN`, secrets are not passed to the runner when a workflow is triggered from a forked repository. The `GITHUB_TOKEN` has read-only permissions in pull requests from forked repositories." [Events that trigger workflows](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request) The same page adds that "Workflows triggered by Dependabot pull requests are treated as though they are from a forked repository, and are also subject to these restrictions," and that a first-time contributor's runs may need a maintainer's approval before they start.

A missing secret does not stop the workflow. The secrets guide says: "If a secret has not been set, the return value of an expression referencing the secret ... will be an empty string." [Using secrets in GitHub Actions](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets) A step that passes an empty token to a sandbox API fails on authentication, and a step guarded on the secret's presence is skipped.

## A fictional public repository with a sandbox test

Suppose `acme/widgets` is public and requires `test` on `main`. The `test` job runs unit tests and then an integration test against a payment provider's sandbox, using the secret `SANDBOX_KEY`. For maintainers, whose pull requests come from branches in the repository, everything passes. For the first outside contributor, the integration step fails with an authentication error, the required check is red, and the pull request cannot merge. The contributor's code is fine.

A maintainer makes the failure go away with the pattern the workflow syntax reference documents for optional secrets, setting the secret as a job environment variable and guarding the step on it ([workflow syntax: using secrets](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#example-using-secrets)):

```
jobs:
  test:
    runs-on: ubuntu-latest
    env:
      SANDBOX_KEY: ${{ secrets.SANDBOX_KEY }}
    steps:
      - uses: actions/checkout@v6
      - run: npm ci
      - run: npm test
      - name: Integration test
        if: ${{ env.SANDBOX_KEY != '' }}
        run: npm run test:integration
```

Now fork pull requests pass `test` without running the integration test, and nothing on the pull request says so. A contributor's change to the payment client merges on unit tests alone. The block became a gap, which is harder to see.

The next suggestion is usually to switch the trigger to `pull_request_target`, which runs with the base repository's secrets and a read/write token. GitHub's guide shows the result as its insecure example: a `pull_request_target` workflow that checks out `github.event.pull_request.head.sha` and runs `make test`, executing "a `Makefile` taken from the pull request head" with "the base repository's secrets and token." It calls this a "pwn request" and says it "has been the root cause of multiple supply-chain compromises." [Securely using pull\_request\_target](https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target#risks-of-pull_request_target) The same guide describes an `actions/checkout` protection against checking out fork pull request refs, which a workflow opts out of with `allow-unsafe-pr-checkout: true`. On 2026-11-23 it also said that a default policy blocking the event in public repositories was in evaluate mode, with enforcement announced for December 2, 2026 on repositories that were using that default before general availability.

## Split the checks

Separate what any pull request can prove from what needs a secret.

```
name: ci
on:
  pull_request:
  merge_group:

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - run: npm ci
      - run: npm test
      - run: npm run test:integration -- --use-recorded-fixtures
```

```
name: integration-live
on:
  push:
    branches: [main]
  workflow_dispatch:

jobs:
  integration-live:
    runs-on: ubuntu-latest
    environment: sandbox
    steps:
      - uses: actions/checkout@v6
      - run: npm ci
      - run: npm run test:integration
        env:
          SANDBOX_KEY: ${{ secrets.SANDBOX_KEY }}
```

The required check `test` runs the same way for everyone and fails honestly. The `--use-recorded-fixtures` flag stands for whatever secret-free version of the test your project can build, such as recorded responses or a local fake. The live test runs where secrets exist: after merge, or on demand by a maintainer against a branch in the repository. When a fork change touches the payment client, a maintainer who has read the change can push the contributor's commits to a branch in `acme/widgets` and run `integration-live` on that branch with `workflow_dispatch`; that run does not come from a fork, so it gets the secrets.

Do not require `integration-live` on pull requests. It does not run on pull request events, and checks from a `workflow_dispatch` run do not satisfy a required check ([troubleshooting required status checks](https://docs.github.com/en/pull-requests/how-tos/merge-and-close-pull-requests/troubleshooting-required-status-checks#checks-from-some-workflow-jobs-are-not-evaluated)), so requiring it would block every pull request, a worse dead end than the one the team started from.

## What the split does not catch

The live test now runs after merge for fork changes, so a defect that only the sandbox reveals reaches `main` before anyone sees it. That is a deliberate trade, and it needs an owner who watches `integration-live` on `main` and reverts. Recorded fixtures catch changes in your code, not changes in the provider's behavior.

Secrets are only one difference. A fork pull request can also edit the workflow that runs on it, because `pull_request` runs the workflow file from the pull request's merge commit; see [a pull request that edits its own workflow](/learn/pull-request-edits-its-own-workflow/).

## What it costs

Maintaining a secret-free test path is real work, and recorded fixtures go stale. Pushing contributor commits to an internal branch costs maintainer time per pull request. The alternative costs are worse but quieter: a required check that outside contributors cannot pass, or one that [skips and passes](/learn/skipped-job-satisfies-required-check/).

## The decision

Require only checks that run identically on fork pull requests, Dependabot pull requests and maintainers' branches. Run tests that need secrets on trusted events, and give their post-merge failures an owner. If you must use `pull_request_target`, use it for labeling or commenting, never to check out and run the pull request's code with secrets.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [When a skipped job satisfies a required check](/learn/skipped-job-satisfies-required-check/)
    
    Code review The Proofline team November 23, 2026 5 min read
    
-   ### [Stop a pull request from weakening the check that judges it](/learn/pull-request-edits-its-own-workflow/)
    
    Code review The Proofline team November 23, 2026 4 min read
