Skip to content
Source
Sign inSign up

Move from GitHub Actions

CI / Start

Move from GitHub Actions

Your CI is in .github/workflows/*.yml, and it runs only on GitHub. Follow these steps to run the same checks on TanStack Source.

8 min read

src ci convert converts each workflow into a TypeScript workflow in .source/workflows/. It converts by rules. For each part that no rule covers, it writes a // TODO(convert) comment. You finish the TODOs, run each job on your machine until it passes, and push.

You need:

  • Admin access to the repository on TanStack Source, because secrets and branch rules are admin settings.
  • The src CLI, logged in. Step 1 shows how.

The examples use tanstack/ai. It has 12 workflows: 7 move, 4 stay on GitHub, and zizmor is dropped. Steps 1 to 5 run on your machine. Steps 6 to 8 put the workflows live.

1. Install the src CLI and log in

Install and set up the CLI shows how. Then list the CI commands:

src ci help

convert, plan and run work without a login. The commands that read from the forge or change it use your src login and the repository of your git remote.

2. Convert the workflows

Run src ci convert in the root of the repository. Without paths, it converts every file in .github/workflows/. To keep a workflow on GitHub, leave its file out (see What does not move today). For tanstack/ai:

src ci convert .github/workflows/pr.yml .github/workflows/e2e.yml .github/workflows/bun-test.yml \
  .github/workflows/autofix.yml .github/workflows/release.yml .github/workflows/sync-models.yml \
  .github/workflows/coverage.yml
.github/workflows/pr.yml -> .source/workflows/pr.ts: 12 TODOs
.github/workflows/e2e.yml -> .source/workflows/e2e.ts: 12 TODOs
.github/workflows/bun-test.yml -> .source/workflows/bun-test.ts: 3 TODOs
.github/workflows/autofix.yml -> .source/workflows/autofix.ts: 2 TODOs
.github/workflows/release.yml -> .source/workflows/release.ts: 12 TODOs
.github/workflows/sync-models.yml -> .source/workflows/sync-models.ts: 12 TODOs
.github/workflows/coverage.yml -> .source/workflows/coverage.ts: 3 TODOs
Converted 7 files with 56 TODOs in total.
Finish each TODO(convert), then check each job with src ci run <workflow> <job>.

src ci convert does not replace a file that exists. To replace it, add --force.

3. Read the TODO list

Each // TODO(convert): <reason> comment is at the workflow, job or step that it is about. The reason says what has no counterpart, and often what to do. These are 3 of the 12 TODOs in e2e.ts:

// TODO(convert): the input key of actions/cache reads ${{ hashFiles('testing/e2e/package.json') }}, but built-in steps take fixed values
// TODO(convert): the condition steps.playwright-cache.outputs.cache-hit != 'true' has no counterpart; the step is off until it is converted
// TODO(convert): this step ran only after a failed step (failure()), but a failed step stops the job here; the step is off

To list all of them, run this command:

grep -rn "TODO(convert):" .source/workflows/

Warning

src ci plan accepts the files with their TODOs. But a step or a job that waits for a TODO is off (if: () => false) or left out. Finish every TODO before you push.

4. Finish the TODOs

Do the work by hand, or give it to a coding agent:

  • By hand: do what each reason says. Then delete the comment. The table of counterparts gives the TanStack Source part for each GitHub Actions part. Finish a converted e2e workflow finishes the 6 TODOs of the e2e upload steps. The reference has every step and option.
  • With the agent skill: give your agent the skill tanstack-source-ci. It is the file skills/tanstack-source-ci/SKILL.md in the npm package @tanstack-source/ci, and it has the fix for each kind of TODO.
  • With MCP: connect your agent to the MCP server of the forge (/mcp). Then start the prompt convert_github_actions. To move one workflow, give its path as the file argument.

The agent finishes the TODOs, runs src ci plan, and runs each job until it passes.

Note

The TODO of the TanStack/config setup action asks for a src: import. After you add the import, run src ci update. It pins the module in .source/src.lock, and downloads it for your editor and for local runs. On a new checkout, src ci sync downloads the pinned modules. See Share steps.

5. Run each job until it passes

Run src ci plan first. Then run each job with src ci run.

src ci plan
src ci run pr test
src ci run e2e e2e --matrix shard=1 --docker
  • src ci plan shows each workflow and its jobs, or the errors. For tanstack/ai, it ends with 7 workflows, 11 jobs.
  • src ci run <workflow> <job> runs one job on your machine. Run it again until it exits with 0.
  • --matrix shard=1 runs one cell of a matrix job.
  • --with-needs runs the jobs that the job needs first, and gives it their outputs.
  • --docker runs the job in its CI image (node or browser), as the forge does.

A local run has the trust level local, and it reads secrets from the environment and from .env. See Run CI jobs on your machine.

6. Add the CI secrets and variables

A secret has one value for each CI environment that needs it. It also has the hosts that the value can go to, and the header it goes in. tanstack/ai needs two secrets:

src secret set NX_CLOUD_ACCESS_TOKEN --env preview --host cloud.nx.app --header Authorization < nx-read-only.txt
src secret set NX_CLOUD_ACCESS_TOKEN --env production < nx-read-write.txt
src secret set NPM_TOKEN --env production --host registry.npmjs.org --header Authorization < npm-publish.txt

The value comes from stdin, so it stays out of your shell history.

  • Pull request runs that use preview get the read-only Nx Cloud token. Only jobs in production, which takes protected runs only, get NPM_TOKEN.
  • If a job with secrets names no environment on GitHub, the converter gives it environment: 'development', with a TODO. Set the environment that the job takes its secret values from.
  • The converter declares each secret as { optional: true }. If a job cannot work without a secret, delete optional: true.
  • The release job publishes with NPM_TOKEN, so declare NPM_TOKEN on the job. The converter turns its id-token: write into permissions: { idToken: true }, but npm does not accept the OIDC token of TanStack Source yet.
  • The converted files read secrets.GITHUB_TOKEN as the run token, TSS_TOKEN. It needs no secret.

Trust levels and secrets explains each level and environment.

If a workflow reads vars.<NAME>, set each variable too. The converter declares it on the job in vars.

src variable set REGION --body eu-west

CI variables has the rules.

7. Push to main

Commit .source/ on main. Then push it to the repository on TanStack Source, and list the runs:

git add .source/
git commit -m "ci: run CI on TanStack Source"
git push
src ci runs --branch main

Push to the default branch before you open pull requests. A pull request run takes the secrets, permissions and egress of its jobs from the base branch. So a job that is new in a pull request runs with none of them.

On tanstack/ai, the push starts autofix, coverage, e2e and release. Run src ci runs --branch main until each run shows success. If a run fails, src ci view <run> --log-failed shows the logs of its failed jobs.

Tip

The gh commands work too: src run list --branch main, src run watch <run> and src run view <run> --log-failed.

8. Add branch rules

A branch rule lets main take changes only through pull requests. It also blocks a merge until the required checks pass.

src ci rule set main --require-pull --check pr/test --check e2e/e2e-result
Set the branch rule main: requires a pull request; required checks pr/test, e2e/e2e-result.
  • A required check is <workflow>/<job>. The checks come from the plan of the base branch, so add the rule after step 7.
  • A push to a branch with a rule is protected, like a push to main. If you publish from alpha, beta or rc, add a rule for each of them. Without a rule, a push there is trusted, and the release job gets no NPM_TOKEN.

Branch rules has every option.

Done

The runs of the push to main pass:

src ci runs --branch main
ID                                    STATUS   WORKFLOW  EVENT  REF   COMMIT
0b7d9c41-6e2a-4f3b-8d15-a9c2e7f04b6d  success  release   push   main  4e5f6a7
c3a18f72-9d4e-4b06-a5e1-7f2b8c9d0e13  success  e2e       push   main  4e5f6a7
8e2f4a6b-1c3d-4e5f-9a7b-0c1d2e3f4a5b  success  coverage  push   main  4e5f6a7
5d6e7f80-a1b2-4c3d-8e4f-5a6b7c8d9e0f  success  autofix   push   main  4e5f6a7

The converted workflows run on TanStack Source, and they pass. From now on, a pull request into main merges only when pr/test and e2e/e2e-result passed on its head commit.

Reference

GitHub Actions to TanStack Source

GitHub ActionsTanStack Source
actions/checkoutBuilt in. Each job checks out the commit of the run. fetch-depth is checkout: { depth } on the job.
actions/cachecache({ key, paths, restoreKeys })
actions/cache with if: steps.<id>.outputs.cache-hit != 'true' on the next stepcache: { inputs, outputs } on that step (step cache)
actions/upload-artifactartifact({ name, paths, retentionDays })
actions/setup-node, oven-sh/setup-bun, pnpm/action-setupsetup.node(), setup.bun(), setup.pnpm()
TanStack/config/.github/setupA src: import, like src:tanstack/config@<tag>/ci/setup.ts
nrwl/nx-set-shasBuilt in: ctx.base and ctx.head
autofix-ci/actionfixup({ message })
gh pr, gh issue, gh labelforge(ctx) in a do step
A bot comment that the workflow posts on a pull request and edits on each runctx.surface.set(key, { title, markdown, buttons }): a live card of the workflow on the pull request. src ci convert does not convert it. See Show results on a pull request.
changesets/actionA port by hand with forge(ctx). The forge creates no releases.
on: pull_request, on: pushpullRequest(), push()
on: workflow_dispatchmanual({ inputs })
on: scheduleschedule(cron)
on: workflow_runafter(workflow, { conclusion }). When the conditions check github.event.workflow_run.conclusion == 'success', the conclusion is 'success'. Without such a check, it is 'any'.
if: on a jobif: (ctx) => ... on the job. always() and !cancelled() become when: 'always', and failure() becomes when: 'on-failure'.
github.repository, github.repository_ownerRead from ctx.env.TSS_REPO. A comparison ignores case, as on GitHub.
concurrency with cancel-in-progress: truecancelOlderRuns, which is on by default
${{ secrets.X }}A secret that the job declares, with a value for each CI environment, the hosts that it can go to and its header
${{ vars.X }}A CI variable that the job declares in vars. The converter adds the declaration. The steps read the value from the environment, as $X or ctx.env.X.
gh run, gh workflow, gh secret, gh variable, gh cache on your machineThe same commands in src. See gh commands for CI.
permissionspermissions, typed, with a ceiling from the trust level of the run
permissions: { id-token: write }permissions: { idToken: true }, and ctx.idToken({ audience }) in a step. See Deploy to a cloud with OIDC.

ctx.base is the commit to compare with: the base of a pull request, or, for a push, the head of the last run of the workflow that passed on that branch. ctx.head is the commit that the run tests.

What does not move today

  • Releases. The forge has no releases. The changesets/action port publishes to npm and opens the version pull request, but it creates no release.
  • npm provenance and trusted publishing. A job gets an OIDC token for AWS, Google Cloud or Azure, but npm and PyPI do not accept a TanStack Source token yet. Publish with an NPM_TOKEN secret.
  • GraphQL scripts. maintainer-sweep and maintainer-scorecard call the GitHub GraphQL API, so they stay on GitHub.
  • AI review. ai-review and ai-review-signal stay on GitHub. On the forge, the software factory runs agents on each pull request.
  • zizmor. It is dropped. The forge checks each workflow file when it plans it.

Keep the workflows that stay on GitHub in .github/workflows/. Do not give their files to src ci convert.