Trunk Flaky Tests identifies repositories by their git remote URL, not by the API token. You can safely use the same organization API token across multiple repositories, including forks, without mixing test results.Documentation Index
Fetch the complete documentation index at: https://trunk-4cab4936-sam-gutentag-fork-pr-uploads-flaky-tests.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
How Repository Identification Works
When the Trunk Analytics CLI uploads test results, it reads the git remote URL from your CI environment and parses it into three components:- Host:
github.com,gitlab.com, or your self-hosted instance - Owner: The organization or user (e.g.,
your-company) - Name: The repository name (e.g.,
your-repo)
Using Trunk with Forks
If you run tests from a fork, Trunk automatically keeps test results separate based on the fork’s remote URL. For example, if your company forksmetabase/metabase to your-company/metabase-fork:
| Repository | Remote URL | Trunk Repo ID |
|---|---|---|
| Original | github.com/metabase/metabase | metabase/metabase |
| Your fork | github.com/your-company/metabase-fork | your-company/metabase-fork |
No special configuration is needed for forks. As long as your fork has a different remote URL (which it does by default), Trunk keeps the data separate automatically.
Verifying Your Remote URL
Before setting up uploads, verify your CI job is using the correct remote URL:Overriding Repository Detection
In some CI environments, you may need to manually specify the repository URL:- The git remote is not available or is incorrect
- You are uploading results from a build artifact without a git checkout
- A shallow clone has modified remotes
--repo-url flag:
TRUNK_REPO_URL environment variable:
Monorepo with Multiple Test Suites
To track different test suites within the same repository separately, use the--variant flag:
Troubleshooting
Test results appearing in wrong repository
- Check your git remote: Run
git remote -vin your CI job to verify the URL. - Check CI environment variables: Some CI providers override git configuration.
- Use explicit override: Set
--repo-urlto force the correct repository.
Duplicate repositories in dashboard
This can happen if the same repository is uploaded with different URL formats (e.g., HTTPS vs SSH). To resolve:- Standardize the remote URL format across all CI jobs.
- Use
--repo-urlto set a consistent URL. - Contact support@trunk.io to merge duplicate repository entries.
Uploading from Fork PR Workflows
GitHub Actions workflows triggered bypull_request events from forks run with read-only permissions and cannot access repository secrets. This means fork PRs cannot use $TRUNK_API_TOKEN to upload test results.
Trunk provides a public repo identifier to solve this. It is a non-secret 8-character code scoped to one repository. Fork PR workflows paste it directly into their workflow YAML instead of using the org API token.
This option is intended for public repositories accepting external contributions. For private repositories or internal forks, use the standard
$TRUNK_API_TOKEN approach instead.Enable fork PR uploads
- Go to Settings in the Trunk web app.
- Open the Repositories section and select the repository.
- Under Flaky Tests, find Fork PR Uploads and toggle Accept uploads from fork PRs on.
- Copy the Public repo identifier that appears below the toggle.
Use the identifier in GitHub Actions
Add a separate workflow file that runs onpull_request events and passes the identifier via the X-Trunk-Public-Repo-Id header. Because the identifier is not a secret, you can commit it directly in the YAML.
How authorization works
When a fork PR workflow uploads using a public repo identifier, Trunk:- Looks up the repository tied to that identifier and confirms fork PR uploads are enabled.
- Verifies the GitHub Actions run ID against the GitHub API to confirm the workflow was triggered by a legitimate fork PR event.
- Associates the upload with the fork’s repository (identified by its remote URL) within your organization.
FAQ
| Question | Answer |
|---|---|
| Can I use the same API token for multiple repos? | Yes. The token is org-scoped, not repo-scoped. |
| Will fork test results mix with upstream? | No. Repos are identified by remote URL, not by token. |
| Do I need separate tokens for forks? | No. The same token works for all repos in your organization. |
| Can I override the detected repository? | Yes. Use --repo-url or the TRUNK_REPO_URL environment variable. |
| Can fork PR workflows upload without a secret? | Yes. Enable fork PR uploads in repository settings to get a public repo identifier. |