Repository navigation
Description
Motivation
Elastic runs a post-gh aw compile script (wire_ephemeral_token.py) so OIDC-minted tokens are preferred over secrets-only env bindings, and so minting jobs get id-token: write. Frontmatter can already use mixed steps.create-token.outputs.token || secrets… expressions (gh-aw ≥ v0.89.21), but a bare compile on v0.92.5 still leaves residual secrets-only lines and missing id-token permissions. That keeps an Elastic-only post-process in the loop and blocks dropping it.
Summary
When a compiled workflow includes a create-token step, the compiler should:
- Prefer
steps.create-token.outputs.token || …on compiler-emitted token env bindings in those minting jobs (not only on authoredgithub-token:fields). - Ensure
permissions.id-token: writeon every job that mintscreate-token.
Context
Verified on elastic/oblt-aw with compiler v0.92.5: gh aw compile --purge then compare to the wire script.
Locks that still need post-processing
gh-aw-dependency-review.lock.ymlgh-aw-onboard-repository.lock.yml
Residuals after bare compile (wire still rewrites)
| Kind | Examples |
|---|---|
| Secrets-only env | GH_AW_GITHUB_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN }} on check-oauth-tokens / lockdown; SECRET_GH_AW_GITHUB_TOKEN; some GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} checkout-manifest steps |
| Missing permission | id-token: write absent on activation / conclusion / safe_outputs even though those jobs contain id: create-token |
Authored frontmatter mixed expressions for tools/safe-outputs github-token already look correct after compile. The gap is compiler-generated env/permissions lines.
Proposal
In the compiler emit path for workflows that mint via create-token:
- When writing
GH_AW_GITHUB_TOKEN,SECRET_GH_AW_GITHUB_TOKEN, checkoutGH_TOKEN, and similar residual bindings inside jobs that containid: create-token, emitsteps.create-token.outputs.token || <existing secrets fallback chain>. - Do not invent
steps.create-tokenreferences in non-minting jobs. - Add
id-token: writetopermissionsfor every job that containsid: create-token(if not already present).
That would let consumers delete post-compile token wiring once they upgrade past the fix.
Scope
| In scope | Out of scope |
|---|---|
Residual env + id-token for create-token minting jobs |
Changing collaborator / TRUSTED_BOT_PR_ACTIONS / labeled checkout |
| Tests/fixtures proving bare compile needs no consumer post-process for these cases | Elastic-specific TokenPolicy / Vault product changes |
Acceptance criteria
- Bare
gh aw compileon a workflow withcreate-tokenemits minted-preferring expressions for the residual env bindings listed above (or equivalent compiler-owned names). - Those minting jobs include
permissions.id-token: write. - Jobs without
create-tokenkeep secrets-only fallbacks (no danglingsteps.create-tokenrefs). - Documented or tested so a consumer can drop a post-compile wire script and still get a green compile-drift check.
References
- Consumer post-process: https://github.com/elastic/oblt-aw/blob/main/scripts/wire_ephemeral_token.py
- Mixed frontmatter support (partial): gh-aw ≥ v0.89.21
- Prove-out compiler pin: v0.92.5
Activity