Skip to content

Commit 1662610

Browse files
📖 [Docs]: Reusable workflows with co-located composite actions (#45)
Reusable workflows that have co-located composite actions can now be correctly documented. This guide explains how to structure a reusable workflow so that its own composite actions are found and executed correctly, regardless of whether the workflow is invoked on a tagged release or a development branch. The pattern uses `job.workflow_repository` and `job.workflow_sha` context variables (available on GitHub.com and GitHub Enterprise Cloud) to ensure the reusable workflow checks itself out before calling any local actions — avoiding the common pitfall where action paths resolve to the caller's repository instead of the workflow's own repository. ## Technical Details Added a new section "Reusable workflows with co-located composite actions" to `src/docs/Coding-Standards/GitHub-Actions.md`: - Explains the problem: reusable workflows run in the caller's workspace, so relative action paths resolve to the wrong repository - Provides the solution: use `job.workflow_repository` and `job.workflow_sha` to self-checkout the reusable workflow first - Includes a complete YAML example showing the pattern - Documents availability on GitHub.com and GHEC (not available on GHES) Aligns with the same section added to AI-Platform documentation to ensure consistency across organizations.
1 parent f527e23 commit 1662610

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎src/docs/Coding-Standards/GitHub-Actions.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,12 @@ build.
581581
to an overview and a pointer into those docs. The README is always present;
582582
it is the entry point, not the whole manual.
583583

584-
## Reusable workflows with co-located composite actions
584+
## Reusable workflows with colocated composite actions
585585

586586
When a reusable workflow (`on: workflow_call`) has its own composite actions
587587
(stored in `.github/actions/` alongside it), those actions are initially local
588588
to a single workflow — the workflow itself. If a reusable workflow is the only
589-
caller of such an action, it should stay co-located and not be promoted to a
589+
caller of such an action, it should stay colocated and not be promoted to a
590590
standalone repository.
591591

592592
**The problem:** A reusable workflow runs in the *caller's* checked-out workspace,
@@ -613,7 +613,7 @@ workflow being executed, not the caller.
613613

614614
```yaml
615615
jobs:
616-
# Reusable workflow with co-located composite actions
616+
# Reusable workflow with colocated composite actions
617617
my-task:
618618
runs-on: ubuntu-24.04
619619
permissions:
@@ -628,7 +628,7 @@ jobs:
628628
ref: ${{ job.workflow_sha }}
629629
path: workflow
630630

631-
# Now call the co-located action from the workflow's path
631+
# Now call the colocated action from the workflow's path
632632
- name: Run the workflow's action
633633
uses: ./workflow/.github/actions/my-action
634634
with:

0 commit comments

Comments
 (0)