|
| 1 | +--- |
| 2 | +title: Sharing Workflows |
| 3 | +description: Share, reuse, and govern workflows across repositories and organizations. |
| 4 | +sidebar: |
| 5 | + badge: { text: 'Platform', variant: 'tip' } |
| 6 | +--- |
| 7 | + |
| 8 | +:::caution[Evolving guidance] |
| 9 | +Enterprise workflow sharing capabilities are actively expanding. Details in this guide may change as the platform matures. |
| 10 | +::: |
| 11 | + |
| 12 | +Sharing workflows across repositories is an organization practice, not a single design pattern. GitHub Agentic Workflows supports multiple layers of sharing, from installing a complete workflow into a repository to parameterized imports and cross-repository execution. |
| 13 | + |
| 14 | +The recommended enterprise pattern is one central `agentic-workflows` repository that publishes versioned workflow templates and shared components. Consuming repositories install full workflows with `gh aw add` and pull in shared modules through `imports:`. |
| 15 | + |
| 16 | +## Sharing Layers |
| 17 | + |
| 18 | +### Layer 1: Copy or install whole workflows |
| 19 | + |
| 20 | +A repository can pull in a complete workflow from another repository using `gh aw add`: |
| 21 | + |
| 22 | +```bash |
| 23 | +gh aw add acme-org/agentic-workflows/ci-doctor@v1.2.0 |
| 24 | +``` |
| 25 | + |
| 26 | +`gh aw add-wizard` provides interactive guidance for the same operation. When a workflow is installed, a `source:` field is added to its frontmatter so the origin is tracked. Updates can then be applied later with `gh aw update`. |
| 27 | + |
| 28 | +Version references support semantic tags (`@v1.2.0`), branches (`@main`), and commit SHAs for strict pinning. |
| 29 | + |
| 30 | +### Layer 2: Reusable workflow components |
| 31 | + |
| 32 | +Shared pieces such as common MCP server configuration, security setup steps, or reusable prompt fragments can be imported by any workflow: |
| 33 | + |
| 34 | +```yaml |
| 35 | +imports: |
| 36 | + - acme-org/shared-workflows/shared/security-setup.md@v2.1.0 |
| 37 | + - acme-org/shared-workflows/shared/mcp/tavily.md@v1.0.0 |
| 38 | +``` |
| 39 | +
|
| 40 | +Imports compose into the consuming workflow at compile time. Frontmatter fields such as `tools:`, `network:`, and `mcp-servers:` are merged so imported configuration is additive. |
| 41 | + |
| 42 | +### Layer 3: Parameterized templates |
| 43 | + |
| 44 | +Shared workflows can accept inputs so the same template is usable across teams with different requirements: |
| 45 | + |
| 46 | +```yaml |
| 47 | +imports: |
| 48 | + - uses: acme-org/shared-workflows/shared/reviewer.md@v1 |
| 49 | + with: |
| 50 | + languages: ["go", "typescript"] |
| 51 | + severity: "high" |
| 52 | +``` |
| 53 | + |
| 54 | +The `uses` / `with` syntax makes it possible to share workflows that have team-specific settings while keeping a single maintained source. |
| 55 | + |
| 56 | +### Layer 4: Versioning and update flow |
| 57 | + |
| 58 | +Enterprise sharing depends on a predictable versioning model: |
| 59 | + |
| 60 | +- **Semantic versions** (`@v1.2.0`) for stable workflows that consuming teams can pin. |
| 61 | +- **Branch refs** (`@main`, `@develop`) for pre-release versions during active development. |
| 62 | +- **SHA pins** for strict reproducibility when drift must be ruled out. |
| 63 | + |
| 64 | +Use `gh aw update` to pull upstream changes into installed workflows: |
| 65 | + |
| 66 | +```bash |
| 67 | +gh aw update # update all tracked workflows |
| 68 | +gh aw update ci-doctor # update a specific workflow |
| 69 | +``` |
| 70 | + |
| 71 | +Updates apply a three-way merge that preserves local edits while incorporating upstream changes. |
| 72 | + |
| 73 | +### Layer 5: Private and internal sharing controls |
| 74 | + |
| 75 | +Not every workflow should be available for installation everywhere. GitHub Agentic Workflows supports access-based controls: |
| 76 | + |
| 77 | +- **`private: true`** in workflow frontmatter blocks `gh aw add` from installing that workflow into other repositories. |
| 78 | +- Repository and organization visibility settings control who can read the workflow sources at all. |
| 79 | +- `gh aw add` performs access checks before installation and surfaces warnings for workflows from untrusted sources. |
| 80 | +- Org-internal workflow catalogs can be created using organization repositories with appropriate visibility settings. |
| 81 | + |
| 82 | +```yaml |
| 83 | +--- |
| 84 | +private: true |
| 85 | +--- |
| 86 | +``` |
| 87 | + |
| 88 | +### Layer 6: Import caching and lock behavior |
| 89 | + |
| 90 | +Remote imports are resolved at compile time and cached in `.github/aw/imports/` by commit SHA. This means: |
| 91 | + |
| 92 | +- Compiled `.lock.yml` files are fully reproducible: the exact import content is pinned at compile time. |
| 93 | +- Offline compilation works once imports have been downloaded. |
| 94 | +- The SHA cache is shared across refs that resolve to the same commit, reducing redundant network calls. |
| 95 | + |
| 96 | +The `.lock.yml` file and the `.github/aw/imports/` directory should both be committed to the repository so workflow runs are reproducible across environments. |
| 97 | + |
| 98 | +### Layer 7: Cross-repository execution model |
| 99 | + |
| 100 | +Separate from sharing workflow definitions, workflows can operate across repositories at runtime: |
| 101 | + |
| 102 | +- Read other repositories using GitHub tool access configured with appropriate permissions. |
| 103 | +- Check out code from other repositories using cross-repository checkout. |
| 104 | +- Create safe outputs (issues, pull requests, comments) in target repositories using `target-repo` and `allowed-repos`. |
| 105 | +- Explicit authentication (PAT or GitHub App token) and allowlists control which repositories a workflow may write to. |
| 106 | + |
| 107 | +This execution model is covered in detail in [Cross-Repository Workflows](/gh-aw/reference/cross-repository/) and [MultiRepoOps](/gh-aw/patterns/multi-repo-ops/). |
| 108 | + |
| 109 | +## Governance Questions |
| 110 | + |
| 111 | +When workflows are shared across an organization, the important questions are usually operational rather than technical: |
| 112 | + |
| 113 | +- Who owns the source workflow and approves changes. |
| 114 | +- How updates are reviewed and promoted from the central repository to consuming repositories. |
| 115 | +- Which repositories may consume or dispatch to shared workflows. |
| 116 | +- How secrets, permissions, and safe outputs are standardized across teams. |
| 117 | +- When teams may fork a workflow rather than stay on the shared source. |
| 118 | + |
| 119 | +Those decisions affect reliability more than the file format does. |
| 120 | + |
| 121 | +## Related Documentation |
| 122 | + |
| 123 | +- [Reusing Workflows](/gh-aw/guides/packaging-imports/) |
| 124 | +- [Imports Reference](/gh-aw/reference/imports/) |
| 125 | +- [Frontmatter Reference](/gh-aw/reference/frontmatter/) (source, private, resources fields) |
| 126 | +- [Cross-Repository Workflows](/gh-aw/reference/cross-repository/) |
| 127 | +- [SideRepoOps](/gh-aw/patterns/side-repo-ops/) |
| 128 | +- [MultiRepoOps](/gh-aw/patterns/multi-repo-ops/) |
0 commit comments