Skip to content
Source
Sign inSign up

Add a hidden workflow

CI / Secrets and trust

Hidden workflows

Some checks must stay out of reach of the people that they check, like a check that the license stays MIT. A hidden workflow is a workflow file that the forge keeps in the vault, for admins only.

3 min read

A file in .source/workflows/ is in git: everyone who reads the repository can read it, and a pull request can change it. A hidden workflow runs next to the workflows of the repository. Contributors see only its result, a summary, and a command to reproduce it.

You need admin access to the repository, and src, logged in.

1. Write the workflow file

Use the same format as the files in .source/workflows/ (see Your first workflow). Keep the file out of the repository, for example in ~/hidden/license.ts:

import { defineWorkflow, pullRequest } from '@tanstack-source/ci'

export default defineWorkflow('license', { on: [pullRequest({ branches: ['main'] })] }).job('check', {
  steps: [{ name: 'Check the license', run: 'grep -q "MIT License" LICENSE' }],
})

Note

A job of a hidden workflow reaches the hosts of its egress, as other jobs do. In an untrusted run, like a pull request from a fork, it reaches no host, so it cannot download packages there.

2. Save it

In a clone of the repository, run:

src hidden-check set license \
  --script-file ~/hidden/license.ts \
  --repro-command 'grep "MIT License" LICENSE' \
  --failure-summary 'The license must stay MIT.' \
  --success-summary 'The license is MIT.'
  • The name uses lowercase letters, digits and dashes.
  • Contributors see the repro command and the summaries.
  • Add --fixable when contributors can make the check pass on their own.

In the browser, open the repository, then Settings, then CI under Code. Under Hidden workflows, fill in the form, and click Save hidden workflow.

3. See it next to the other workflows

Open the folder .source/workflows/ of the repository. The hidden workflow shows there as license.ts, with a lock icon and a Hidden workflow badge. Only admins see it.

The folder .source/workflows: the workflow ci.ts from git, and the hidden workflow nightly.ts with a lock icon and the Hidden workflow badge
  1. Click license.ts. The vault file page opens.
  2. Click Reveal to read the file.

To change the file, run src hidden-check set again, or save it again under Hidden workflows in Settings, CI. To delete it, run src hidden-check delete license.

4. Make sure that it runs

The forge checks the file on the next push or pull request. If the file has errors, Hidden workflows in Settings, CI shows them under "It does not run".

To block a merge until it passes, add its job to a branch rule as hidden:license/check. See Hidden checks as required checks.

Done

The check runs on each pull request into main. You see the file next to your other workflows. Contributors see only whether it passed, and how to reproduce it.

What a hidden workflow cannot do

  • It gets no permission to write. See Permissions.
  • In an untrusted run, its jobs reach no host. The code of that run can read the hidden file, so the forge gives it no way to send the file out.
  • It sends no fixup() and saves no cache.
  • It never runs on a runner app. See How the forge picks the runner.
  • Its file, logs, findings and artifacts are for admins only.