fix(agreements): mint GitHub App installation token in-job#73
Conversation
The previous calling pattern (see splunk/addonfactory-repository-template
enforce/.github/workflows/agreements.yaml) mints a GitHub App installation
token in a separate `generate-token` job and tries to pass it to
`call-workflow-agreements` via `jobs.<id>.outputs.token`. GitHub Actions
strips secret-classified values from job outputs ("Skip output 'token'
since it may contain secret"), so the downstream job receives an empty
PERSONAL_ACCESS_TOKEN and the contributor-assistant action fails with:
Please add a personal access token as an environment variable for
writing signatures in a remote repository/organization ...
Could not retrieve repository contents. Status: unknown
Example failing run:
https://github.com/splunk/splunk-add-on-for-crowdstrike-fdr/actions/runs/27142130630
This change moves the token mint into the same job that consumes it:
- Adds optional GH_APP_CLIENT_ID / GH_APP_PRIVATE_KEY secrets.
- Generates an installation token scoped to splunk/cla-agreement before
invoking contributor-assistant/github-action.
- Falls back to the legacy PERSONAL_ACCESS_TOKEN secret when App
credentials are not supplied, keeping existing callers working.
- GH_TOKEN is now optional and defaults to github.token.
Callers can simplify to:
jobs:
call-workflow-agreements:
uses: splunk/addonfactory-github-workflows/.github/workflows/reusable-agreements.yaml@vX.Y
secrets:
GH_APP_CLIENT_ID: ${{ secrets.GH_APP_CLIENT_ID }}
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
Co-authored-by: Cursor <cursoragent@cursor.com>
GitHub Actions does not allow the `secrets` context inside step-level `if:` expressions (only github, needs, vars, env, inputs are allowed), which caused the reusable workflow to fail validation in the caller with a 0-second workflow file error. Move the App-creds presence check to job-level `env.HAS_APP_CREDS` (secrets context IS allowed in job env), then condition the create-github-app-token step on `env.HAS_APP_CREDS == 'true'`. Co-authored-by: Cursor <cursoragent@cursor.com>
cc43ad4 to
277e0e0
Compare
End-to-end test: GREENTested against A throwaway workflow on that PR calls secrets:
GH_APP_CLIENT_ID: ${{ secrets.GH_APP_CLIENT_ID }}
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}Result: https://github.com/splunk/splunk-add-on-for-crowdstrike-fdr/actions/runs/27171499098
The action successfully authenticated to Note about the testThe end-to-end run required momentarily widening the
A prior intermediate run with the production |
|
🎉 This PR is included in version 1.7.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Problem
Add-on repos rolled out from
splunk/addonfactory-repository-templatenow fail the CLA/COC check on every PR, e.g.:with:
Root cause
The template's caller workflow mints a GitHub App installation token in a separate
generate-tokenjob and passes it via job outputs tocall-workflow-agreements:GitHub Actions auto-classifies the App installation token as a secret and strips it from job outputs with the annotation:
So
needs.generate-token.outputs.tokenresolves to an empty string,PERSONAL_ACCESS_TOKENis empty in the consuming job, andcontributor-assistant/github-actionrejects the call. This calling pattern cannot be made to work — the App token must be minted in the same job that consumes it.Change
reusable-agreements.yamlnow mints the App token inside each job when App credentials are supplied:GH_APP_CLIENT_IDandGH_APP_PRIVATE_KEY.splunk/cla-agreementis generated viaactions/create-github-app-token@v3immediately before invokingcontributor-assistant/github-action@v2.6.1.PERSONAL_ACCESS_TOKENwhen App credentials are not provided (back-compat with existing callers).GH_TOKENis now optional and defaults togithub.token.Callers using App-token auth can simplify to:
No
generate-tokenjob, no PAT.Backwards compatibility
Fully backwards compatible:
PERSONAL_ACCESS_TOKEN(legacy)GH_APP_CLIENT_ID+GH_APP_PRIVATE_KEYGH_TOKENis now optional; existing callers passing it continue to work.Test plan
End-to-end test via downstream PR — patches
splunk-add-on-for-crowdstrike-fdrPR #971 to call this branch'sreusable-agreements.yamlwith the App secrets. Will link the green run here before merge.Made with Cursor