Skip to content

gh aw add rewrites {{#import shared/X.md}} with incorrect cross-repo path (resolves from repo root instead of .github/workflows/) #23212

Description

@johnpreed

Bug Description

When installing a workflow from a remote repository via gh aw add, body-level {{#import shared/X.md}} directives are rewritten to cross-repo imports. This causes two distinct problems:

Problem 1: Unwanted rewriting of intentionally-local imports

gh aw add rewrites ALL {{#import shared/X.md}} directives to cross-repo paths pinned to the source repository (e.g., {{#import github/source-repo/shared/X.md@SHA}}). There is no way to indicate that an import should remain local — resolved from the consuming repository's own .github/workflows/shared/ directory rather than fetched from the source.

This breaks the shared workflow library pattern where a source repo publishes reusable workflows, but consuming repos provide their own local shared/ files with repo-specific or team-specific configuration.

Problem 2: Incorrect cross-repo path resolution

Even if the cross-repo rewriting were desired, the rewritten path is wrong. gh aw add resolves shared/X.md from the repository root instead of .github/workflows/shared/X.md, causing a 404.

Steps to Reproduce

  1. In a source repository, create a workflow at .github/workflows/my-workflow.md containing:

    {{#import shared/config.md}}
  2. The shared file exists at .github/workflows/shared/config.md in the source repo (compiles fine locally).

  3. In a consuming repository, provide a local .github/workflows/shared/config.md with repo-specific content.

  4. Install the workflow:

    gh aw add github/source-repo/.github/workflows/my-workflow.md --force
  5. The import is rewritten to:

    {{#import github/source-repo/shared/config.md@abc123}}
  6. Compilation fails:

    ✗ error: failed to resolve required include 'github/source-repo/shared/config.md@abc123'
    HTTP 404: Not Found
    (https://github.com/ghapi/repos/github/source-repo/contents/shared/config.md?ref=abc123)
    

Expected Behavior

{{#import shared/config.md}} should remain unchanged after gh aw add, resolving locally in the consuming repository. Not all shared imports should be pinned to the source repo — some are intentionally local.

Actual Behavior

gh aw add rewrites the import to a cross-repo path:

{{#import github/source-repo/shared/config.md@abc123}}

This is wrong in two ways:

  1. It pins to the source repo instead of staying local
  2. It resolves from the repo root (shared/config.md) instead of .github/workflows/shared/config.md

Impact

Every gh aw add and presumably gh aw update requires a manual post-install fix to revert the rewritten imports, making the install/update cycle non-idempotent.

Environment

  • gh aw version: v0.64.2

Desired Outcome

  1. Primary ask: Provide a way to mark body-level {{#import}} directives as "local-only" so they are not rewritten during gh aw add. These imports should resolve from the consuming repo's local .github/workflows/shared/ directory.

  2. Secondary ask: If cross-repo import rewriting is kept for some cases, fix the path resolution so it uses the correct full path (.github/workflows/shared/X.md) instead of resolving from the repo root (shared/X.md).

Activity

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions