Sample workflows

Pull request tests with the repository's secrets

pull_request_target checks out the pull request's code and runs npm on it.

A workflow triggered by pull_request_target runs in the base repository, with its secrets and a token that can usually write, even when the pull request comes from a fork. This one checks out the pull request's head commit and runs npm ci and npm test on it, so a pull request can change package.json or a test and run anything it likes with TEST_API_KEY in reach.

Since July 2026 actions/checkout refuses to check out a fork's code on this trigger, so the workflow sets allow-unsafe-pr-checkout: true, as workflows that depend on the pattern now have to. actionlint 1.7.12 predates that input and reports it as unknown.

Since December 2, 2026 GitHub also blocks pull_request_target in public repositories by default. This workflow would still run in a private repository, or in a public one whose Actions policy allows the event.

# Runs the tests of every pull request, including ones from forks, with the# repository's secrets: pull_request_target plus a checkout of the PR's code.name: Test pull requests on:  pull_request_target:    types: [opened, synchronize, reopened] jobs:  test:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v4        with:          ref: ${{ github.event.pull_request.head.sha }}          allow-unsafe-pr-checkout: true      - uses: actions/setup-node@v4        with:          node-version: 22      - run: npm ci      - run: npm test        env:          API_KEY: ${{ secrets.TEST_API_KEY }}