Skip to content

Commit 49575d1

Browse files
authored
fix: mint the App token inside the pull-request job, not a separate one (#433)
#432's generate-token job passed its token to pull-request via needs.generate-token.outputs.token. actions/create-github-app-token masks its token output as a secret, and GitHub Actions silently empties masked values when forwarded through a job's `outputs:` to a downstream job ("Skip output 'token' since it may contain secret" in the run log) — it only survives steps within the job that generated it. Confirmed in signalwire/pricing-calculator: checkout failed with "Input required and not supplied: token" even though Generate GitOps PR token succeeded, because the forwarded value was empty. Move the create-github-app-token step into the pull-request job itself and reference steps.generate-token.outputs.token directly, instead of a separate generate-token job.
1 parent 150fdba commit 49575d1

1 file changed

Lines changed: 18 additions & 29 deletions

File tree

.github/workflows/gitops-values-bump.yml

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,6 @@ jobs:
7878
echo "::error::APP_ID is required when MODE is pull-request."
7979
exit 1
8080
81-
# Mints a short-lived token from a GitHub App to open the review PR.
82-
# pull-request mode never relies on the reusable GITHUB_TOKEN for this —
83-
# many orgs disable "Allow GitHub Actions to create pull requests" as
84-
# policy, which makes GITHUB_TOKEN-based PR creation fail workflow
85-
# *validation* entirely (not just at runtime) the moment a caller's job
86-
# requests pull-requests: write. An externally-authenticated App token
87-
# isn't subject to that restriction and needs no permissions grant from
88-
# the caller at all.
89-
generate-token:
90-
name: Generate GitOps PR token
91-
needs: [validate]
92-
if: ${{ inputs.MODE == 'pull-request' }}
93-
runs-on: ubuntu-latest
94-
permissions: {}
95-
outputs:
96-
token: ${{ steps.generate-token.outputs.token }}
97-
steps:
98-
- name: Generate a token
99-
id: generate-token
100-
uses: actions/create-github-app-token@v3
101-
with:
102-
app-id: ${{ inputs.APP_ID }}
103-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
104-
10581
direct-commit:
10682
name: Bump ${{ inputs.YQ_PATH }} -> ${{ inputs.IMAGE_TAG }} (direct commit)
10783
needs: [validate]
@@ -140,18 +116,31 @@ jobs:
140116
141117
pull-request:
142118
name: Bump ${{ inputs.YQ_PATH }} -> ${{ inputs.IMAGE_TAG }} (PR)
143-
needs: [validate, generate-token]
119+
needs: [validate]
144120
if: ${{ inputs.MODE == 'pull-request' }}
145121
runs-on: ubuntu-latest
146122
# No GITHUB_TOKEN permissions requested — all git/gh operations below
147-
# authenticate as the App token from generate-token instead, so this
148-
# job's validity doesn't depend on the org's GITHUB_TOKEN PR policy.
123+
# authenticate as the App token minted in this same job instead, so
124+
# this job's validity doesn't depend on the org's GITHUB_TOKEN PR
125+
# policy. The token must be minted here rather than in a separate job:
126+
# actions/create-github-app-token masks its output as a secret, and
127+
# GitHub silently empties masked values when forwarded through a job's
128+
# `outputs:` to another job (see "Skip output 'token' since it may
129+
# contain secret" in the run log) — it only survives within the job
130+
# that generated it.
149131
permissions: {}
150132
steps:
133+
- name: Generate a token
134+
id: generate-token
135+
uses: actions/create-github-app-token@v3
136+
with:
137+
app-id: ${{ inputs.APP_ID }}
138+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
139+
151140
- uses: actions/checkout@v7
152141
with:
153142
ref: ${{ inputs.TARGET_BRANCH }}
154-
token: ${{ needs.generate-token.outputs.token }}
143+
token: ${{ steps.generate-token.outputs.token }}
155144

156145
- name: Bump value
157146
env:
@@ -170,7 +159,7 @@ jobs:
170159
PR_TITLE: ${{ inputs.PR_TITLE }}
171160
PR_BODY: ${{ inputs.PR_BODY }}
172161
COMMIT_MESSAGE: ${{ inputs.COMMIT_MESSAGE }}
173-
GH_TOKEN: ${{ needs.generate-token.outputs.token }}
162+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
174163
run: |
175164
git config user.email "github-actions[bot]@users.noreply.github.com"
176165
git config user.name "github-actions[bot]"

0 commit comments

Comments
 (0)