Skip to content

Commit 3e07436

Browse files
Copilotcraxal
andcommitted
fix: use gh auth login --with-token to persist auth into gh store for copilot CLI
Co-authored-by: craxal <3473026+craxal@users.noreply.github.com>
1 parent 6c06680 commit 3e07436

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

.github/workflows/stale-issue-cleanup.yml

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,27 @@ name: Stale Issue Cleanup
22

33
# # Authentication
44
#
5-
# This workflow uses a single secret, `STALE_ISSUES_TOKEN`, for all operations, set as
6-
# both `COPILOT_GITHUB_TOKEN` and `GH_TOKEN`.
5+
# This workflow uses a single secret, `STALE_ISSUES_TOKEN`, set as `GH_TOKEN`.
76
#
87
# `STALE_ISSUES_TOKEN` is a Classic PAT with the following scopes:
9-
# - `copilot` — required by the Copilot CLI for model inference.
10-
# Set as `COPILOT_GITHUB_TOKEN` (the first env var the CLI checks).
11-
# The CLI does not reliably honour `GH_TOKEN` for Copilot model auth,
12-
# so this must be set explicitly.
13-
# - `repo` — lets the gh CLI comment on and close issues (via `GH_TOKEN`)
8+
# - `copilot` — required by the Copilot CLI for model inference
9+
# - `repo` — lets the gh CLI comment on and close issues
1410
# - `read:org` — required to list members of the microsoft/azure-storage-explorer team
1511
# - `project` — required to update the Resolution field on the org-level project
1612
#
17-
# Note: `github.token` (the built-in Actions token) cannot be used for Copilot auth —
18-
# it is a machine installation token, rejected by the Copilot CLI regardless of any
19-
# `permissions: models: read` setting. A user PAT with the `copilot` scope is required.
13+
# The `copilot` CLI reads auth from gh's persistent auth store, not from env vars directly.
14+
# `echo "$GH_TOKEN" | gh auth login --with-token` writes the token into that store so
15+
# `copilot` can find it. `GH_TOKEN` is still read by the `gh` CLI for subsequent API calls.
16+
#
17+
# Note: `github.token` cannot be substituted here — it is a machine installation token
18+
# that the Copilot CLI rejects. A user PAT with the `copilot` scope is required.
2019
#
2120
# `read:org` and `project` are org-level scopes that cannot be granted to `github.token`
2221
# via the `permissions` block, which is why an external PAT is always required here.
2322
#
24-
# For production, consider replacing this PAT with a GitHub App token for the gh CLI calls,
25-
# using `actions/create-github-app-token`. A GitHub App cannot hold a Copilot seat, so
26-
# `COPILOT_GITHUB_TOKEN` will always require a user PAT with the `copilot` scope.
23+
# For production, consider using a GitHub App token for the `gh` CLI calls and keeping a
24+
# dedicated user PAT (with `copilot` scope) for Copilot inference, since a GitHub App
25+
# cannot hold a Copilot seat.
2726
#
2827
# # Install Step Note
2928
#
@@ -50,21 +49,11 @@ jobs:
5049
curl -fsSL https://gh.io/copilot-install | bash
5150
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
5251
53-
- name: Diagnostics
54-
env:
55-
GH_TOKEN: ${{ secrets.STALE_ISSUES_TOKEN }}
56-
run: |
57-
echo "Token prefix: ${GH_TOKEN:0:12}"
58-
echo "Token length: ${#GH_TOKEN}"
59-
copilot --version
60-
echo '--- gh auth status ---'
61-
gh auth status
62-
6352
- name: Run stale issue cleanup agent
6453
env:
65-
COPILOT_GITHUB_TOKEN: ${{ secrets.STALE_ISSUES_TOKEN }}
6654
GH_TOKEN: ${{ secrets.STALE_ISSUES_TOKEN }}
6755
run: |
56+
echo "$GH_TOKEN" | gh auth login --with-token
6857
copilot \
6958
--agent issue-manager \
7059
--prompt "Find and close stale bug issues." \

0 commit comments

Comments
 (0)