copilot-setup-steps.yml Examples for Copilot Cloud Agent
When you hand a task to GitHub Copilot cloud agent (GitHub renamed it from Copilot coding agent in April 2026), it works in a fresh, short-lived environment. If your project needs Node 22, a lockfile install, a Rust toolchain or a database, Copilot can try to set that up by trial and error, which GitHub's docs call "slow and unreliable". The fix is one file: .github/workflows/copilot-setup-steps.yml. It's a normal GitHub Actions workflow with one job, and its steps run before Copilot starts working.
Short answer: put a workflow at .github/workflows/copilot-setup-steps.yml with one job named exactly copilot-setup-steps, give it contents: read, install from your lockfile, keep timeout-minutes at 59 or less, and merge it to the default branch. Then start the Copilot task on Actions, not Cloud.
The catch people miss in late 2026: setup steps only run when the session runs on GitHub Actions. Sessions in a cloud sandbox skip the file completely, and where a client lets you choose, Cloud is the default. The checklist under "Why your setup steps don't run" covers it.
We checked everything here on 2026-11-28 against GitHub's docs: Configure the development environment for agents on GitHub Actions, secrets and variables for Copilot cloud agent, About cloud sandboxes and the firewall page. Action versions are the current releases on that date.
Download free-copilot-setup-steps.zip (MIT: 10 ready files for npm, pnpm, Postgres, uv, pip, Go, Rust, Maven, .NET and Git LFS, plus check-copilot-setup-steps.py, which checks your file against the rules on this page, and a 69-test test.sh. Every template passes actionlint.)
The rules, in one table
| Rule | What GitHub's docs say |
|---|---|
| Path | Exactly .github/workflows/copilot-setup-steps.yml |
| Branch | It won't trigger until the file is on your default branch |
| Job name | One job, named exactly copilot-setup-steps, or Copilot doesn't pick it up |
| Honoured keys | Only steps, permissions, runs-on, services, snapshot and timeout-minutes. Anything else on the job is ignored |
| Timeout | timeout-minutes can be at most 59 |
| Checkout | Optional. If you don't check out, Copilot does it after your steps. Any fetch-depth you set is overridden |
| Failures | If a step exits non-zero, Copilot skips the remaining steps and starts work anyway |
| Runners | Ubuntu x64 or Windows 64-bit only. macOS isn't supported |
That "ignored" row matters. env:, container:, environment:, strategy: and if: are all valid Actions syntax, so the workflow runs fine on its own, and the problem only shows up in Copilot's session. Put environment variables on individual steps instead.
The base file
This is GitHub's example with tighter comments. Every template in the kit starts like this:
name: "Copilot Setup Steps"
# Runs when this file changes (so you see whether it works) and by hand from the Actions tab.
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
jobs:
copilot-setup-steps: # must be exactly this name
runs-on: ubuntu-latest
timeout-minutes: 20 # max 59
permissions:
contents: read # for actions/checkout; Copilot gets its own token for its work
steps:
- uses: actions/checkout@v7
# your setup steps go here
The push and pull_request triggers are filtered to this one file, so it runs as a normal check on the pull request that adds it, and you see right away whether it works. GitHub's example uses both; trim to what you need. workflow_dispatch lets you rerun it from the Actions tab once it's merged. (GitHub's example uses actions/checkout@v6; v7 is the current major.)
Examples by stack
Each block replaces the steps: part of the base file. The full files are in the zip.
Node.js with npm:
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version-file: package.json # reads engines.node; or node-version: "22"
cache: npm
- run: npm ci
Use npm ci, not npm install. It installs exactly what the lockfile says and fails if package.json and the lockfile disagree, which is a problem you want to see before Copilot starts editing.
pnpm:
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6 # version from "packageManager" in package.json
- uses: actions/setup-node@v7
with:
node-version: "22"
cache: pnpm
- run: pnpm install --frozen-lockfile
Python with uv:
steps:
- uses: actions/checkout@v7
- uses: astral-sh/[email protected] # no floating v10 tag: pin a release
with:
enable-cache: true
- run: uv sync --locked
Python with pip:
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.12"
cache: pip
- run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
Go:
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version-file: go.mod # module cache is on by default
- run: go mod download && go build ./...
Rust:
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo build --locked --all-targets
Building once here means Copilot's first cargo build is incremental rather than from scratch.
Java (Maven) and .NET follow the same pattern: actions/setup-java@v6 with distribution: temurin and cache: maven, then mvn -B -ntp -DskipTests package; or actions/setup-dotnet@v6 with global-json-file: global.json, then dotnet restore. Both are in the zip.
A database for integration tests. services is one of the six honoured keys, so Copilot can have a real Postgres while it works:
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: app
POSTGRES_PASSWORD: app # throwaway, local to the runner
POSTGRES_DB: app_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U app"
--health-interval 5s
--health-retries 10
Tell Copilot the connection string in your AGENTS.md or copilot-instructions.md, or it won't know the database is there.
Git LFS. Without this, Copilot gets LFS pointer files instead of your assets:
- uses: actions/checkout@v7
with:
lfs: true
Bigger, self-hosted and Windows runners
Change runs-on and nothing else:
- Larger GitHub-hosted runners: set up larger runners for your organization, then use their label, for example
runs-on: ubuntu-4-core. - Self-hosted runners: use your runner or ARC scale set label. GitHub recommends ephemeral, single-use runners. You must turn off Copilot's firewall for the repo, because the firewall doesn't work with self-hosted runners and Copilot is blocked until you do. Control the network yourself instead.
- Windows: use a Windows label on a larger or self-hosted runner. The firewall isn't compatible with Windows either, so GitHub recommends self-hosted runners or larger runners with Azure private networking.
- macOS and ARM: not supported. Copilot cloud agent runs only on Ubuntu x64 and Windows 64-bit runners.
Organization owners can also set a default runner type for every repo, and decide whether repos can override it.
Secrets and private registries
Copilot doesn't see your Actions secrets. It has its own Agents secrets and variables: repo Settings > Secrets and variables > Agents (organizations have the same page). If you used the old copilot environment, GitHub moved those values to Agents automatically.
- Agents secrets and variables are exposed as environment variables, to the commands Copilot runs and to your setup steps. Read them as
$NPM_TOKENin a script. - Names starting with
COPILOT_MCP_are the exception. They go only to MCP servers, so a setup step can't use them. - Names can only use letters, numbers and underscores, can't start with a number or
GITHUB_, and are case-insensitive. - Values are masked in session logs.
The firewall also matters here. It covers the processes Copilot starts through its shell, not processes started in your setup steps. So a private registry Copilot can't reach mid-session can still be installed from during setup. Don't treat that as a security hole to lean on: the token is still in the environment Copilot works in.
Why your setup steps don't run
Go down this list in order. The checker flags the ones it can see.
- The session ran in a cloud sandbox. Sessions can run in a cloud sandbox GitHub hosts ("Cloud") or on GitHub Actions ("Actions"). Setup steps, larger and self-hosted runners and Windows only work on Actions. Where a client lets you choose, Cloud is the default, and you can't switch after the session starts. Sessions started from github.com chat, GitHub Mobile, Slack, Teams, the Copilot app and VS Code use a cloud sandbox by default. Pick Actions when you delegate the task. (Cloud sandboxes have their own settings at github.com/copilot/customize, and you can bring personal instructions and skills through a dotfiles repo with a
.copilotfolder.) - The file isn't on the default branch. A pull request that adds it runs it as a check, but Copilot uses it only after it's merged.
- The job name is off.
copilot_setup_steps,setuporCopilot-Setup-Stepsare just other jobs. - The setting you changed is ignored.
env,container,environmentandstrategyon the job do nothing for Copilot. - An early step failed. Copilot skips every step after the first failure and starts anyway. Open the session log (the "View session" link on the pull request) and find the first red step.
- Checkout failed on permissions. If you set
permissions:withoutcontents: read,actions/checkoutcan't clone. - The timeout is over 59. Use 59 or less.
- The secret is in the wrong place. Actions secrets and
COPILOT_MCP_names don't reach setup steps.
Check your file with the free script
python3 -m pip install pyyaml
python3 check-copilot-setup-steps.py . # from your repo root
python3 check-copilot-setup-steps.py --file draft.yml # any file
Typical output:
== ./.github/workflows/copilot-setup-steps.yml
ERROR E10 timeout-minutes is 90; the maximum Copilot allows is 59
WARN W09 job key `env:` is ignored by Copilot; only steps, permissions, runs-on, services, snapshot, timeout-minutes are honoured (put `env:` on individual steps instead)
WARN W30 .github/workflows/copilot-setup-steps.yml is not on origin/main (as of your last fetch). It won't run until it's merged into the default branch
-- 1 error(s), 2 warning(s)
Note: setup steps only run when the session runs on GitHub Actions. Sessions in a cloud sandbox (the default where you can choose Cloud or Actions) skip this file.
It checks the path and file name, the job name (and suggests the closest one), the six honoured keys, the 59-minute limit, macOS/ARM/Windows/self-hosted runners, permissions against actions/checkout, unpinned actions, COPILOT_MCP_ and secrets.* in steps, Git LFS in .gitattributes without lfs: true, a copilot-code-review.yml override, and whether the file is on the default branch. Add --strict to fail on warnings in CI.
We also ran it on the copilot-setup-steps.yml files in 9 public repos (including microsoft/vscode, dotnet/runtime, microsoft/playwright and github/awesome-copilot). None had errors. Two had warnings: one sets env: on the job, which isn't on GitHub's list of honoured keys, and one has no permissions: block. That run also caught a false alarm in our own checker (secrets.GITHUB_TOKEN, the built-in job token, is fine), which we fixed. What we didn't do: run the templates inside a real Copilot session. They're linted with actionlint and the checker, not field-tested.
Copilot code review uses this file too
Copilot code review also runs in a short-lived environment, and by default it reuses copilot-setup-steps.yml. If you want a different setup for reviews, add .github/workflows/copilot-code-review.yml. When that file exists, code review uses it instead. Code review has its own firewall section on the same Internet access settings page.
FAQ
Is copilot-setup-steps.yml required? No. Copilot works without it and installs what it can by itself. The file makes setup faster and repeatable, and it's the only way to give Copilot private dependencies, services, larger runners or Windows.
Does it run on every push? Only when this file changes, if you use the triggers above, plus whenever Copilot starts a session on Actions. It isn't your CI.
Will my CI run on Copilot's pull requests? Not automatically. GitHub Actions workflows don't run when Copilot pushes. Click Approve and run workflows in the pull request's merge box.
Should I run the test suite in setup? Usually not. It adds minutes before every session, and Copilot runs tests anyway when your instructions tell it how. Install and build once, then write the test command in AGENTS.md or .github/copilot-instructions.md.
How long can a session take? Setup steps are capped at 59 minutes. Separately, GitHub's troubleshooting page says a session on Actions that stays stuck times out after an hour.
Pair it with instructions Copilot reads
Setup gets the tools installed. Instructions tell Copilot what to do with them: which test command to run, which folders not to touch. See copilot-instructions.md examples, why Copilot ignores your instructions and how to write AGENTS.md. The free AGENTS.md generator drafts AGENTS.md and copilot-instructions.md from your package.json or pyproject.toml.
AgentKit Co is not affiliated with GitHub. GitHub and Copilot are trademarks of GitHub, Inc.
AI Coding Agent Config Kit · $14 · 30-day refund
Tell Copilot which commands to run
AGENTS.md templates for 12 stacks, a CLAUDE.md with .claude/rules, 8 Cursor .mdc rules, Copilot instructions and 12 prompts that draft, audit and trim them. No setup-steps files; the free kit above covers those.
Not ready to buy? Get our free Agent Skills pack on Gumroad (pay what you want, $0 is fine; Gumroad asks for your email to deliver it). Get the free skills