Add GH_TOKEN to Install gh-aw extension step#1994
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pelikhan
reviewed
Oct 19, 2025
Copilot
AI
changed the title
[WIP] Update compiler to pass GitHub token to gh cli
Add GH_TOKEN to Install gh-aw extension step
Oct 19, 2025
Contributor
|
Agentic Changeset Generator triggered by this pull request. |
Collaborator
|
Use helper to resolve the correct GitHub token (see GH_AW_GITHUB_TOKEN) @copilot |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Contributor
Author
Updated to use
The install step now generates: env:
GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}Added tests for both default and custom token scenarios. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The "Install gh-aw extension" step in compiled workflows was missing the
GH_TOKENenvironment variable, which is required by theghCLI for authentication. This caused the installation step to fail when the workflow runs in GitHub Actions.The
ghCLI requires the GitHub token to be available asGH_TOKENwhen performing operations that interact with the GitHub API, including installing extensions.Solution
Updated the compiler in
pkg/workflow/mcps.goto include theGH_TOKENenvironment variable in the "Install gh-aw extension" step. The token usesgetEffectiveGitHubToken()helper function to resolve the correct token with proper precedence:github-tokenfrom frontmatter (if specified)${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}Additionally, simplified the install command to remove the upgrade fallback (
|| gh extension upgrade githubnext/gh-aw) since the workflow runs in a fresh container where the extension is never pre-installed.Before
After (default token)
After (with custom github-token in frontmatter)
Changes
GH_TOKENenvironment variable to the install stepgetEffectiveGitHubToken()helper to resolve the correct token with precedence supportTestAgenticWorkflowsInstallStepIncludesGHTokento verify the default token is usedTestAgenticWorkflowsInstallStepWithCustomTokento verify custom token precedenceTesting
This follows the same pattern used elsewhere in the codebase for steps that invoke
ghcommands (e.g.,push_to_pull_request_branch.go,create_issue.go) and uses the same token resolution helper (getEffectiveGitHubToken) used throughout the workflow package.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.