Copilot CLI supports authentication with personal access tokens (PATs), which makes it easy to run inside CI/CD environments such as GitHub, GitLab, Jenkins, and Azure DevOps. Integrating the CLI lets you bring Copilot’s assistance into these pipelines and extend how you use Copilot beyond the editor.
In this lab we will:
- Integrate Copilot CLI into a GitHub Actions workflow so every new PR triggers an automated review.
- Use Azure OpenAI in the same workflow to summarize the Copilot CLI findings and post them back to the PR.
- Note: the example focuses on code review, but you can customize the workflow for other scenarios.
- Node.js: >= 22.0.0
- npm: >= 10.0.0
- VS Code: latest version
- GitHub Copilot: signed in
Generate a personal access token.
-
Create the PAT Navigate to Developer settings → Personal access tokens → Tokens (classic), click Generate new token, and store it securely.

- The token is generated and saved locally.
Add secrets to the repository.
-
Open the repository settings On GitHub, open the target repository and go to Settings.
-
Create secrets Under Secrets and variables → Actions, click New repository secret and add the following (use the PAT from Step 1 for
COPILOT_CLI_PAT):COPILOT_CLI_PAT AZURE_OPENAI_API_KEY AZURE_OPENAI_BASE_URL AZURE_OPENAI_MODEL
- The secrets are created successfully.
Wire Copilot CLI and Azure OpenAI into the GitHub workflow.
-
Open the local repo in VS Code Make sure you are still on the
feature/testbranchbranch. -
Add the GitHub Actions workflow Create
.github/workflows/pr-copilot-review.yml. Use the example at https://github.com/jacwu/github-materials/blob/main/.github/workflows/pr-copilot-review.yml as a reference. -
Add the Azure OpenAI helper script Create
scripts/normalize_review_result.py. Use https://github.com/jacwu/github-materials/blob/main/scripts/normalize_review_result.py as a reference. -
Commit and push Commit your changes locally and push them. This activates the earlier PR from Step 2 and triggers the new GitHub Actions workflow, which runs the Copilot review and posts the summarized results.




