Skip to content

[Breaking] Migrate Process-PSModule GitHub operations to strict GitHub App token auth#408

Draft
Marius Storhaug (MariusStorhaug) wants to merge 10 commits into
mainfrom
github-app-planning
Draft

[Breaking] Migrate Process-PSModule GitHub operations to strict GitHub App token auth#408
Marius Storhaug (MariusStorhaug) wants to merge 10 commits into
mainfrom
github-app-planning

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

This PR migrates GitHub-facing workflow operations from implicit github.token usage to explicit GitHub App installation-token wiring in the reusable workflow pipeline.

It introduces a generic reusable-workflow secret contract so caller repositories can map their own secret names while Process-PSModule remains stable.

Breaking change

GitHub-facing reusable workflow/action paths now require explicit GitHub App token wiring. Fallback to github.token was removed intentionally.

What changed

  1. Reusable workflow contract and wiring
  • Added required reusable secrets in workflow.yml:
    • GitHubAppClientId
    • GitHubAppPrivateKey
  • Passed those secrets into Plan.yml and Publish-Module.yml calls.
  1. Plan workflow app-token bootstrap
  • Plan.yml now accepts GitHub App secrets.
  • Added pinned actions/create-github-app-token step.
  • Get-PSModuleSettings and Resolve-PSModuleVersion now receive app token via GH_TOKEN and GITHUB_TOKEN.
  1. Publish workflow app-token bootstrap
  • Publish-Module.yml now accepts GitHub App secrets.
  • Added pinned actions/create-github-app-token step.
  • Publish-PSModule and Cleanup-PSModulePrereleases now receive app token via GH_TOKEN and GITHUB_TOKEN.
  1. Action-level strict token behavior
  • Updated these action manifests to require caller-provided token env in the reusable workflow path:
    • .github/actions/Get-PSModuleSettings/action.yml
    • .github/actions/Resolve-PSModuleVersion/action.yml
    • .github/actions/Publish-PSModule/action.yml
    • .github/actions/Cleanup-PSModulePrereleases/action.yml
  • Removed fallback expressions that previously resolved to github.token.
  1. Docs and caller examples
  • Added README section documenting generic reusable secret names and caller mapping.
  • Updated test caller workflows to map repo secrets to reusable names:
    • .github/workflows/Workflow-Test-Default.yml
    • .github/workflows/Workflow-Test-WithManifest.yml

Consumer usage

Callers should provide:

secrets:
  GitHubAppClientId: ${{ secrets.PSMODULE_CLIENT_ID }}
  GitHubAppPrivateKey: ${{ secrets.PSMODULE_PRIVATE_KEY }}

PSMODULE_CLIENT_ID and PSMODULE_PRIVATE_KEY are consumer-side choices; only the reusable-workflow boundary names are fixed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Prefer caller-provided GH_TOKEN/GITHUB_TOKEN for GitHub API/CLI calls while keeping github.token fallback for compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove github.token fallbacks from GitHub-facing composite actions so reusable workflow paths require explicit app-token env wiring.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title Migrate Process-PSModule GitHub operations to GitHub App token auth [Breaking] Migrate Process-PSModule GitHub operations to strict GitHub App token auth Jul 23, 2026
For GitHub App-enabled workflow/action paths, remove dual-token env usage and keep explicit GH_TOKEN-only wiring with no github.token fallback.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mint an installation token in Build-Module.yml (same pinned
actions/create-github-app-token@fee1f7d... as Plan and Publish-Module)
and inject it as GH_TOKEN on the Build-PSModule step.

This covers the three gh repo view calls in Build-PSModuleManifest.ps1
that read repo description, topics, and URL — all of which go through
the gh CLI and therefore consume GH_TOKEN.

The job-level GH_TOKEN: github.token fallback is removed.
workflow.yml is updated to pass the GitHubAppClientId and
GitHubAppPrivateKey secrets into the Build-Module reusable workflow.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Each token-minting step now requests only the permissions the job
actually exercises and restricts the token to the current repository.

Plan:
  repositories: current repo
  permission-contents: read   (gh release list in Resolve-Version)
  permission-pull-requests: write (label/comment via Get-PSModuleSettings)

Publish-Module:
  repositories: current repo
  permission-contents: write  (gh release create/upload/delete)
  permission-pull-requests: write (gh pr comment)

Build-Module:
  repositories: current repo
  (no permission-* needed - only gh repo view which uses metadata:read,
   auto-granted to all GitHub App installations)

This limits blast radius: even if a compromised step obtained GH_TOKEN,
it could only act on the one repository and only with the declared
permission level, not on every repo in the installation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

1 participant