Repository navigation
Description
Summary
When a reusable workflow compiled by gh aw compile is invoked cross-org via workflow_call (caller in org-A, callee/platform repo in org-B, same enterprise), the activation job fails at multiple points. The compiled lock file cannot resolve the correct source repository, cannot check out the callee's files, and cannot verify the frontmatter hash.
This blocks all cross-org central-repo-ops patterns.
Environment
gh-awCLI: v0.67.2gh-aw-actions/setup: v0.67.2 (3922978bff4d7cf117e185580ad108da5a0134d8)- Both organizations are in the same GitHub Enterprise Cloud account
- Callee repository visibility:
internal
Bug 1: resolve_host_repo.cjs resolves to the caller repo
Expected
The "Resolve host repo for activation checkout" step should resolve to the callee (platform) repository so the checkout fetches the correct .github/ and .agents/ content.
Actual
It resolves to the caller repository. The script relies on GITHUB_WORKFLOW_REF (line 38), but in a workflow_call invocation, GITHUB_WORKFLOW_REF points to the top-level caller's workflow — not the reusable workflow being executed.
The code comment on line 14 states:
"GITHUB_WORKFLOW_REF always reflects the currently executing workflow file"
This is incorrect for workflow_call. The GitHub Actions docs confirm that github.workflow_ref resolves to the caller's workflow ref in reusable workflow contexts.
Suggested Fix
Apply the same referenced_workflows API lookup that check_workflow_timestamp_api.cjs already uses (lines 118–157). When the env workflow ref doesn't match the current lock file, query GET /repos/{caller}/actions/runs/{run_id} and find the matching entry in referenced_workflows[] to determine the correct callee repo and ref.
The target_repo_name output is already designed for actions/create-github-app-token (per the comment on line 76–77), confirming that cross-org was anticipated — the resolution logic just wasn't updated.
Bug 2: Checkout step cannot access the callee repo cross-org
Expected
The "Checkout .github and .agents folders" step should successfully clone the callee's repository content.
Actual
The checkout step uses the default GITHUB_TOKEN (no explicit token: parameter). The GITHUB_TOKEN is a GitHub App installation token scoped to the caller's organization. It cannot access repositories in a different org, even if both orgs are in the same enterprise and the callee repo is internal. The checkout fails with:
remote: Repository not found.
Error: fatal: repository 'https://github.com/<callee-org>/<callee-repo>/' not found
Suggested Fix — Two Options
Option A: actions/create-github-app-token integration
When resolve_host_repo detects a cross-org invocation (targetRepo !== currentRepo and different org prefix), the compiled workflow should include a step that mints a short-lived installation token via actions/create-github-app-token. This would require:
- The user to install a GitHub App in both orgs (one-time admin setup)
- App ID and private key stored as secrets, passed via
workflow_callsecrets - The compiled workflow to call
actions/create-github-app-tokenwithowner:andrepositories:(using the existingtarget_repo_nameoutput) to generate a cross-org token - That token is passed to the checkout step and hash check step
This is the standard GitHub-recommended approach for cross-org access.
Option B: Pre-inline all runtime imports during compilation (optional frontmatter flag)
An alternative that requires zero extra token setup: add an optional frontmatter flag (e.g., inline-imports: true or self-contained: true) that causes gh aw compile to inline all {{#runtime-import ...}} content directly into the lock file at compile time, rather than leaving them as runtime directives.
With fully inlined content:
- The cross-org checkout of
.agents/becomes unnecessary (no runtime imports to resolve) - The checkout of
.github/workflows/is only needed for the hash check, which could be made non-fatal or skipped for cross-org scenarios - The lock file becomes entirely self-contained — no runtime file dependencies
This would be particularly helpful for teams using central-repo-ops patterns where the platform repo and caller repos are in different organizations. The trade-off is larger lock files, which is why making it opt-in via frontmatter seems ideal.
Option B would be particularly valuable for our use case — we maintain a central platform repo with reusable agentic workflows consumed by repos across multiple orgs in the same enterprise. Eliminating the cross-org checkout dependency would significantly simplify adoption.
Bug 3: check_workflow_timestamp_api.cjs requires actions: read but the compiler doesn't add it
The hash check step calls github.rest.actions.getWorkflowRun() via the referenced_workflows API lookup (line 124). This requires the actions: read permission on the GITHUB_TOKEN. However, the compiled activation job only declares contents: read in its permissions: block.
Since explicit permissions: restricts the token to only the listed scopes, actions: read is absent and the API call fails with:
Error: Resource not accessible by integration
Suggested Fix
The compiler should add actions: read to the activation job's permissions: whenever it emits the check_workflow_timestamp_api.cjs step.
Reproduction
- Create a reusable workflow in org-B using
gh aw compile - Create a caller workflow in org-A (different org, same enterprise) that uses
workflow_callto invoke the reusable workflow - Run the caller workflow
- Observe:
resolve_host_reporesolves to org-A's repo (wrong)- Checkout clones org-A's repo (no
.agents/or.github/workflows/*.mdpresent) - Hash check fails (no files on disk, API fallback also fails)
Summary of Fixes Needed
| Component | Issue | Fix |
|---|---|---|
resolve_host_repo.cjs |
Uses GITHUB_WORKFLOW_REF which points to caller |
Add referenced_workflows API lookup (same as check_workflow_timestamp_api.cjs) |
| Checkout step (compiled) | No cross-org token | Option A: actions/create-github-app-token integration; Option B: inline-imports frontmatter flag to eliminate runtime checkout |
Compiler (permissions:) |
Missing actions: read |
Add actions: read when emitting hash check step |
Option B (pre-inline with frontmatter flag) would be particularly valuable for our use case and likely for other teams adopting central-repo-ops across org boundaries.
Activity
pelikhan commentedon Apr 6, 2026
There is a inlined-imports front matter flag. The agent should have sugggested it...
pelikhan commentedon Apr 6, 2026
/plan
github-actions commentedon Apr 6, 2026
✅ Plan Command completed successfully!
bbonafed commentedon Apr 6, 2026
Oops, I should have noticed that. Thanks for info
fix: add actions:read permission to activation job when hash check AP…
theletterf commentedon Apr 8, 2026
We're hitting a related issue with cross-repo
workflow_callin v0.67.2 — specifically, the frontmatter hash computed at compile time doesn't match the hash computed at runtime, even though both are v0.67.2.Evidence
After compiling with
gh aw compile(v0.67.2), the lock file metadata contains:But
gh aw hash-frontmatter(also v0.67.2) on the same.mdsource produces a different hash:The runtime verification (
check_workflow_timestamp_api.cjsfromgh-aw-actions/[email protected]) recomputes the hash and gets the same value ashash-frontmatter, so it fails:Context
elastic/docs-actions) instead of the caller (elastic/docs-content). The.mdsource and lock file are both found.compileembeds and what the runtime recomputes from the same file.inlined-imports: true— same result (different hashes, but still mismatched).Setup
elastic/docs-actions— public, contains the.mdsource +.lock.ymlelastic/docs-content— public, thin trigger withuses: elastic/docs-actions/...@v1gh awCLI andgh-aw-actions/setupat v0.67.2pelikhan commentedon Apr 10, 2026
@salmanmkc
bbonafed commentedon Apr 10, 2026
Update:
inlined-imports: truedoes not fully resolve cross-orgworkflow_callWe've been using
inlined-imports: trueas recommended (PR #24977), and it successfully eliminates the need for a cross-org checkout of.agents/and.github/content. However, the hash check step (check_workflow_timestamp_api.cjs) still fails in cross-org scenarios.What works
GH_AW_CONTEXT_WORKFLOW_REFcorrectly resolves the callee repo. ✅actions: readto activation job permissions when hash check API step is emitted #24976 — natively included in v0.68.0. ✅inlined-imports: true: Eliminates the cross-org checkout dependency. ✅What still fails
The hash check step calls the GitHub API to fetch the lock file from the callee repo for hash comparison:
The default
GITHUB_TOKENis scoped to the caller's organization and cannot access repositories in a different org, even within the same enterprise. The API call returns 404, the local filesystem fallback (PR #24057) also fails (sinceinlined-imports: truemeans the callee's files aren't checked out locally), and the step fails with:Current workaround
We're patching the compiled lock file to pass a cross-org PAT to the hash check step:
This must be re-applied after every
gh aw compile.Suggestion
The compiler could accept an optional
github-tokenoverride for the hash check step (e.g., via frontmatter orworkflow_callinput), so cross-org users don't need to manually patch lock files. Alternatively, wheninlined-imports: trueis set, the hash check could use only the inlined content for verification rather than requiring API access to the callee repo.pelikhan commentedon Apr 11, 2026
@salmanmkc
pelikhan commentedon Apr 12, 2026
Fixed with new job.workflow_* variables
chore: update community contributions (2026-04-13)