Add copilot-setup-steps.yml for workspace initialization#344
Conversation
Co-authored-by: aldenks <[email protected]>
There was a problem hiding this comment.
This doesn't follow the structure in the docs. Read this: https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment
workflow should be located at .github/workflows/copilot-setup-steps.yml
Preinstalling tools or dependencies in Copilot's environment
In its ephemeral development environment, Copilot can build or compile your project and run automated tests, linters and other tools. To do this, it will need to install your project's dependencies.Copilot can discover and install these dependencies itself via a process of trial and error, but this can be slow and unreliable, given the non-deterministic nature of large language models (LLMs), and in some cases, it may be completely unable to download these dependencies—for example, if they are private.
Instead, you can preconfigure Copilot's environment before the agent starts by creating a special GitHub Actions workflow file, located at .github/workflows/copilot-setup-steps.yml within your repository.
A copilot-setup-steps.yml file looks like a normal GitHub Actions workflow file, but must contain a single copilot-setup-steps job. This job will be executed in GitHub Actions before Copilot starts working. For more information on GitHub Actions workflow files, see Workflow syntax for GitHub Actions.
Note
The copilot-setup-steps.yml workflow won't trigger unless it's present on your default branch.
Here is a simple example of a copilot-setup-steps.yml file for a TypeScript project that clones the project, installs Node.js and downloads and caches the project's dependencies. You should customize this to fit your own project's language(s) and dependencies:
YAML
name: "Copilot Setup Steps"
# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest
# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read
# You can define any steps you want, and they will run before the agent starts.
# If you do not check out your code, Copilot will do this for you.
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
- name: Install JavaScript dependencies
run: npm ci
In your copilot-setup-steps.yml file, you can only customize the following settings of the copilot-setup-steps job. If you try to customize other settings, your changes will be ignored.
steps (see above)
permissions (see above)
runs-on (see below)
services
snapshot
timeout-minutes (maximum value: 59)
For more information on these options, see Workflow syntax for GitHub Actions.Any value that is set for the fetch-depth option of the actions/checkout action will be overridden to allow the agent to rollback commits upon request, while mitigating security risks. For more information, see actions/checkout/README.md.
Your copilot-setup-steps.yml file will automatically be run as a normal GitHub Actions workflow when changes are made, so you can see if it runs successfully. This will show alongside other checks in a pull request where you create or modify the file.
Once you have merged the yml file into your default branch, you can manually run the workflow from the repository's Actions tab at any time to check that everything works as expected. For more information, see Manually running a workflow.
When Copilot starts work, your setup steps will be run, and updates will show in the session logs. See Tracking GitHub Copilot's sessions.
If any setup step fails by returning a non-zero exit code, Copilot will skip the remaining setup steps and begin working with the current state of its development environment.
.github/copilot-setup-steps.yml
Outdated
| - name: Install GDAL | ||
| run: | | ||
| sudo apt-get update -qy | ||
| sudo apt-get install -qy -o APT::Install-Suggests=false libgdal-dev gdal-bin |
There was a problem hiding this comment.
| sudo apt-get install -qy -o APT::Install-Suggests=false libgdal-dev gdal-bin | |
| sudo apt-get install -qy -o APT::Install-Suggests=false gdal-bin |
There was a problem hiding this comment.
Applied in commit 32bb3d6. Removed libgdal-dev and kept only gdal-bin.
Co-authored-by: aldenks <[email protected]>
Fixed in commit 32bb3d6. Moved the file to |
.github/workflows/copilot-setup-steps.ymlas a complete GitHub Actions workflowcopilot-setup-stepsjob (required name for Copilot to recognize it)uvusing astral-sh/setup-uv action (matching code-quality.yml)gdal-binonly) to make gdalinfo availableuv run pre-commit installcommand.github/copilot-setup-steps.ymlfileOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.