Skip to content

Commit 743865f

Browse files
docs: add GitHub App authentication docs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent ece10f3 commit 743865f

4 files changed

Lines changed: 92 additions & 0 deletions

File tree

src/docs/Modules/Process-PSModule/build-test-pack-publish.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ Version progression is label-driven in pull requests and resolved in the plan st
1818

1919
Test and lint stages run before publish gates, and publish is blocked when required checks fail.
2020

21+
## GitHub API authentication
22+
23+
GitHub API interactions in Process-PSModule workflows use GitHub App installation tokens (not `github.token`). For the full permission and scoping model, see [GitHub App Authentication](github-app-authentication.md).
24+
2125
For complete cross-org release capability docs, use [MSX Capabilities](https://msxorg.github.io/docs/Capabilities/).
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# GitHub App Authentication
2+
3+
Process-PSModule uses GitHub App installation tokens for GitHub API operations in the pipeline instead of `github.token`.
4+
5+
## Secret contract at reusable workflow boundary
6+
7+
The root reusable workflow (`workflow.yml`) requires two caller-provided secrets:
8+
9+
- `GitHubAppClientId`: GitHub App Client ID (identifier, not a secret)
10+
- `GitHubAppPrivateKey`: GitHub App RSA private key (sensitive)
11+
12+
Callers map their repository or organization secret names into this contract:
13+
14+
```yaml
15+
secrets:
16+
GitHubAppClientId: ${{ secrets.PSMODULE_CLIENT_ID }}
17+
GitHubAppPrivateKey: ${{ secrets.PSMODULE_PRIVATE_KEY }}
18+
```
19+
20+
## Token minting model
21+
22+
Each workflow that needs GitHub API access mints its own short-lived installation token with a pinned action:
23+
24+
```yaml
25+
- uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349
26+
```
27+
28+
### Plan.yml (settings, version resolution, PR labels)
29+
30+
```yaml
31+
- uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349
32+
with:
33+
app-id: ${{ secrets.GitHubAppClientId }}
34+
private-key: ${{ secrets.GitHubAppPrivateKey }}
35+
repositories: ${{ github.event.repository.name }}
36+
permission-contents: read
37+
permission-pull-requests: write
38+
```
39+
40+
### Publish-Module.yml (release creation, artifacts, PR comments, prerelease cleanup)
41+
42+
```yaml
43+
- uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349
44+
with:
45+
app-id: ${{ secrets.GitHubAppClientId }}
46+
private-key: ${{ secrets.GitHubAppPrivateKey }}
47+
repositories: ${{ github.event.repository.name }}
48+
permission-contents: write
49+
permission-pull-requests: write
50+
```
51+
52+
### Build-Module.yml (repository metadata for module manifest)
53+
54+
```yaml
55+
- uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349
56+
with:
57+
app-id: ${{ secrets.GitHubAppClientId }}
58+
private-key: ${{ secrets.GitHubAppPrivateKey }}
59+
repositories: ${{ github.event.repository.name }}
60+
# no permission-* inputs required here
61+
# gh repo view relies on metadata: read (auto-granted to GitHub Apps)
62+
```
63+
64+
## Token injection pattern
65+
66+
Inject the minted token as `GH_TOKEN` only on steps that call GitHub APIs (for example, `gh` CLI steps). Do not set it job-wide unless every step requires GitHub API access.
67+
68+
## Why GitHub App tokens are used
69+
70+
- identity is app-scoped, not tied to an individual user
71+
- pipeline automation can write where `github.token` is constrained in reusable-workflow fork scenarios
72+
- each token mint is repository-scoped and permission-scoped
73+
- effective permission ceiling is enforced at app installation level
74+
75+
Required installation permissions for Process-PSModule use cases:
76+
77+
- `contents: write`
78+
- `pull-requests: write`
79+
- `metadata: read` (auto-granted)
80+
81+
## Permission model distinctions
82+
83+
1. **Workflow `permissions:` block** controls only `github.token`; it does not change GitHub App installation tokens.
84+
2. **GitHub App installation permissions** are the hard ceiling for any token minted by that app.
85+
3. **`repositories:` input** scopes token reach. Default to `${{ github.event.repository.name }}` unless cross-repo access is intentionally required.
86+
4. **`permission-<scope>:` inputs** request a per-token subset of installation permissions; request only the minimum needed by that workflow.

src/docs/Modules/Process-PSModule/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This section documents how module repositories are formed and how they move from
99
- [Repository Structure](repository-structure.md)
1010
- [Module Anatomy](module-anatomy.md)
1111
- [Build, Test, Pack, Publish](build-test-pack-publish.md)
12+
- [GitHub App Authentication](github-app-authentication.md)
1213
- [Template Quickstart](template-quickstart.md)
1314

1415
For broader framework context, see [MSX Frameworks / Process-PSModule](https://msxorg.github.io/docs/Frameworks/Process-PSModule/).

src/zensical.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ nav = [
3232
{"Repository Structure" = "Modules/Process-PSModule/repository-structure.md"},
3333
{"Module Anatomy" = "Modules/Process-PSModule/module-anatomy.md"},
3434
{"Build, Test, Pack, Publish" = "Modules/Process-PSModule/build-test-pack-publish.md"},
35+
{"GitHub App Authentication" = "Modules/Process-PSModule/github-app-authentication.md"},
3536
{"Template Quickstart" = "Modules/Process-PSModule/template-quickstart.md"},
3637
]},
3738
]},

0 commit comments

Comments
 (0)