Skip to content

Explicitly use GITHUB_TOKEN for role membership checks - #6267

Merged
pelikhan merged 2 commits into
mainfrom
copilot/use-github-action-token
Dec 12, 2025
Merged

pelikhan merged 2 commits into
mainfrom
copilot/use-github-action-token

Conversation

Copilot AI commented Dec 12, 2025 •

Copy link
Copy Markdown
Contributor

Role membership checks must use the GitHub Actions token, not custom secrets like GH_AW_GITHUB_TOKEN or GH_AW_AGENT_TOKEN.

Changes

Modified pkg/workflow/role_checks.go:

  • Added explicit github-token: ${{ secrets.GITHUB_TOKEN }} parameter to check_membership step generation

Added pkg/workflow/role_checks_test.go:

  • Tests verify explicit GITHUB_TOKEN usage
  • Tests verify custom tokens are not present in check_membership steps

Recompiled workflow lock files:

  • All 35+ workflows now have explicit token in check_membership steps

Example

Before:

- name: Check team membership for workflow
  id: check_membership
  uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
  env:
    GH_AW_REQUIRED_ROLES: admin,maintainer,write
  with:
    script: |
      # Permission check logic

After:

- name: Check team membership for workflow
  id: check_membership
  uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
  env:
    GH_AW_REQUIRED_ROLES: admin,maintainer,write
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    script: |
      # Permission check logic

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login it/ref/tags/v5 GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile env action.git GO111MODULE 5587045/b348=> GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login -action.git -action.git /opt/hostedtoolcache/go/1.25.0/x--systemd-cgroup GOINSECURE GOMOD GOMODCACHE go env tags/v6 GO111MODULE e/git by/c4492a94cba91infocmp /" + .name GOMODCACHE e/git (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login -bun.git -bun.git b5e99e9af048032cf35e09b0a05bca982bb/log.json GOINSECURE GOMOD GOMODCACHE 5587045/b374/styles.test e=/t�� t0 GO111MODULE (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

The role membership check MUST use the GitHub action token. It must NOT use any other secret.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot generate comment stating that it must use the secrets.GITHUB_TOKEN value

Copilot AI changed the title [WIP] Implement role membership check using GitHub action token Explicitly use GITHUB_TOKEN for role membership checks Dec 12, 2025
Copilot AI requested a review from pelikhan December 12, 2025 13:52

Copilot AI commented Dec 12, 2025

Copy link
Copy Markdown
Contributor Author

@copilot generate comment stating that it must use the secrets.GITHUB_TOKEN value

The role membership check now explicitly uses secrets.GITHUB_TOKEN for authentication. This ensures that permission checks always use the GitHub Actions token and cannot accidentally use other custom secrets like GH_AW_GITHUB_TOKEN, GH_AW_AGENT_TOKEN, or COPILOT_GITHUB_TOKEN.

The implementation is in commit 9424bbc where:

  • pkg/workflow/role_checks.go adds github-token: ${{ secrets.GITHUB_TOKEN }} to the check_membership step
  • Tests verify that only GITHUB_TOKEN is used and no custom tokens appear in the check_membership section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants