Skip to content

Compiler should emit minted-token env bindings and id-token: write for create-token jobs #72408

Done

Description

@fr4nc1sc0-r4m0n

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:

  1. Prefer steps.create-token.outputs.token || … on compiler-emitted token env bindings in those minting jobs (not only on authored github-token: fields).
  2. Ensure permissions.id-token: write on every job that mints create-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.yml
  • gh-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, checkout GH_TOKEN, and similar residual bindings inside jobs that contain id: create-token, emit steps.create-token.outputs.token || <existing secrets fallback chain>.
  • Do not invent steps.create-token references in non-minting jobs.
  • Add id-token: write to permissions for every job that contains id: 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 compile on a workflow with create-token emits 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-token keep secrets-only fallbacks (no dangling steps.create-token refs).
  • Documented or tested so a consumer can drop a post-compile wire script and still get a green compile-drift check.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions