CI / Secrets and trust
Approve untrusted runs
A run of a pull request from a fork waits, because nobody with write access has read its code yet. Read what the run can do, then start it with one click or one command.
5 min read
You need write access to the repository.
An untrusted run waits until a person with write access approves it. A click on Run checks by that person approves the runs it starts. Agents and jobs never approve. The forge approves by itself in two cases only, by fixed rules in code:
- The runs of a push by a factory agent. See Runs after a push by a factory agent.
- A pull request run whose head has a clean security audit, while the setting Start checks after a clean audit is on. See Start checks after a clean audit.
The approval decides only that the run starts, never what the run can do.
1. Open the waiting run
Open the run page, or the checks of the pull request. The run says that it waits for an approval.
2. Read the warnings
Read the warnings, and the list of what the run can do.
3. Approve the run
Click Approve and run. On the checks of a pull request, one click approves every workflow of the pull request that waits, and the button says how many: Approve and run all 3 waiting workflows. From a terminal, approve one run:
src ci approve <run>
When you click Run checks on the pull request, you approve the runs that it starts. They do not wait for a second click.
Done
The run starts at the untrusted level. Its jobs get no secret value that needs a trusted or protected run, and its token only reads.
What a fork pull request gets
This example uses the pr workflow of Use a secret in a job. You approve its run of a pull request from a fork into main. On the run page:
- The run has the label Untrusted.
previewneeds atrustedrun, so thetestjob is skipped, and gets no value ofNX_CLOUD_ACCESS_TOKEN.- If the pull request adds
NPM_TOKENto its job, the run shows a warning, and the job runs without the secret. - A
git pushor a comment with the run token is refused.
The code of the fork had nothing that can publish.
Tip
To give forks a read-only token, add an environment of your own that takes untrusted pull request runs: src env set forks --ref pull_request --min-trust untrusted. Then name it in the job.
Start checks after a clean audit
Outside contributors open pull requests, and each of their runs waits for you to click Approve and run. You can let a clean security audit start these runs. You need admin access to the repository, or to be an owner of the organization.
- On the repository, open Agents, then click Rules under Software factory in the sidebar. On an organization, open the Software factory tab.
- In the card Rules for all agents, turn on Start checks after a clean audit.
- Click Save rules.
From a terminal, send {"auditStartsChecks": true} with src factory configure --file change.json. See Change the settings with src.
Now a pull request run that waits for an approval starts by itself:
- When a security audit of its head commit ends
clean, the TanStack Source bot approves the run. - When that head already has a clean audit, the bot approves the run at once.
So Run agents on the pull request starts the audit. When the audit ends clean, the checks start, next to the agents that wait for the audit.
What stays the same:
- The run is still
untrusted. It gets no secret values, and its token only reads. - An audit that is not
cleanstarts nothing. The run waits for a person. - Each push needs a clean audit of its own head.
- The Security audit agent must be on. It is on by default.
A run that already waited when you turned the setting on starts at the next clean audit of the same head. To start it now, approve it, or start the audit again.
Runs after a push by a factory agent
A factory agent can push a fix to the head of a pull request: the fixer, the conflict fixer, or CI self-heal. No person pushed that code, so the pull request runs of that commit are always untrusted. They get no secret values, and their token only reads. They act for the author of the pull request, and they start like this:
- If the author has write access, the run starts at once, approved in the name of the author.
- If the author has no write access, the run waits. When the security audit of that commit ends
clean, the TanStack Source bot approves the run. - If the audit is not
clean, or the audit agent is off, the run waits for a person.
A push() run of the same commit has no pull request. It waits for a person.
Hold a protected job for a person
Approval gates hold the jobs of protected runs in the same way. Add a job to the approval gates in the CI settings of the repository, as <job> or <workflow>/<job>. In a protected run, that job waits for Approve and run before it starts.
src ci settings --gate deploy/deploy
--gatesets the list of gates. Give it once for each job.--no-gatesclears the list.- Gates hold the jobs of protected runs only.