Skip to content

Commit 3b4410a

Browse files
Use GitHub App token in Build-Module workflow
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>
1 parent 83568fb commit 3b4410a

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

.github/workflows/Build-Module.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ name: Build-Module
22

33
on:
44
workflow_call:
5+
secrets:
6+
GitHubAppClientId:
7+
description: The client ID of the GitHub App used for repository API calls.
8+
required: true
9+
GitHubAppPrivateKey:
10+
description: The private key of the GitHub App used for repository API calls.
11+
required: true
512
inputs:
613
Settings:
714
type: string
@@ -20,8 +27,6 @@ jobs:
2027
Build-Module:
2128
name: Build-Module
2229
runs-on: ubuntu-latest
23-
env:
24-
GH_TOKEN: ${{ github.token }}
2530
steps:
2631
- name: Checkout Code
2732
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
@@ -37,8 +42,17 @@ jobs:
3742
path: _wf
3843
persist-credentials: false
3944

45+
- name: Create GitHub App token
46+
id: App-Token
47+
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2
48+
with:
49+
app-id: ${{ secrets.GitHubAppClientId }}
50+
private-key: ${{ secrets.GitHubAppPrivateKey }}
51+
4052
- name: Build module
4153
uses: ./_wf/.github/actions/Build-PSModule
54+
env:
55+
GH_TOKEN: ${{ steps.App-Token.outputs.token }}
4256
with:
4357
Name: ${{ fromJson(inputs.Settings).Name }}
4458
Version: ${{ fromJson(inputs.Settings).Publish.Module.Resolution.Version != '' && fromJson(inputs.Settings).Publish.Module.Resolution.Version || '999.0.0' }}

.github/workflows/workflow.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ jobs:
116116
Build-Module:
117117
if: fromJson(needs.Plan.outputs.Settings).Build.Module.Enabled
118118
uses: ./.github/workflows/Build-Module.yml
119+
secrets:
120+
GitHubAppClientId: ${{ secrets.GitHubAppClientId }}
121+
GitHubAppPrivateKey: ${{ secrets.GitHubAppPrivateKey }}
119122
needs:
120123
- Plan
121124
with:

0 commit comments

Comments
 (0)