Skip to content

Add automatic checkout for runtime-import macros#9315

Merged
pelikhan merged 4 commits intomainfrom
copilot/ensure-github-folder-checked-out
Jan 8, 2026
Merged

Add automatic checkout for runtime-import macros#9315
pelikhan merged 4 commits intomainfrom
copilot/ensure-github-folder-checked-out

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 8, 2026

Runtime-import macros ({{#runtime-import filepath}} and @./path) require repository files to be checked out at workflow execution. Previously, users had to manually ensure checkout was configured when using these macros.

Changes

  • Detection: Added containsRuntimeImports() to parse markdown for file-based runtime-import patterns

    • Matches {{#runtime-import filepath}} and {{#runtime-import? filepath}} macros
    • Matches inline syntax @./path and @../path
    • Excludes URL-only imports (http://, https://)
  • Checkout Logic: Modified shouldAddCheckoutStep() to trigger checkout when runtime-imports detected

    • Only adds checkout if contents: read permission exists
    • Respects existing checks (custom steps, agent files)
    • Uses default shallow clone with no persisted credentials
  • Tests: Added 22 tests covering macro patterns, permissions, and compilation flows

Example

Workflow with runtime-import now automatically gets checkout:

---
permissions:
  contents: read
engine: copilot
---

# Agent

{{#runtime-import .github/shared-instructions.md}}

Complete the task.

Compiled workflow includes:

- name: Checkout repository
  uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
  with:
    persist-credentials: false
Original prompt

When the macro runtime-imports is enabled, the compiler should ensure that the .github folder is checked out.

  • permissions: content: read
  • if no checkout required, do a shallow checkout of the .github folder, no persisted credentials.

The reason is that the runtime-import needs to read file from the .github folder


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 8, 2026 05:18
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add containsRuntimeImports function to detect runtime-import macros in markdown content
- Modify shouldAddCheckoutStep to trigger checkout when runtime-imports are detected
- Add comprehensive unit and integration tests
- Tests partially passing, need to fix edge cases for permissions and URL-only imports

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add containsRuntimeImports function to detect runtime-import macros
- Modify shouldAddCheckoutStep to trigger checkout when runtime-imports are detected
- Only add checkout if contents:read permission is present
- Exclude URL-only runtime-imports (http:// or https://)
- Add comprehensive unit and integration tests
- All checkout-related tests passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add check for .github folder during runtime imports Add automatic checkout for runtime-import macros Jan 8, 2026
Copilot AI requested a review from pelikhan January 8, 2026 05:40
@pelikhan pelikhan marked this pull request as ready for review January 8, 2026 05:49
@pelikhan pelikhan merged commit d13b1b9 into main Jan 8, 2026
146 of 147 checks passed
@pelikhan pelikhan deleted the copilot/ensure-github-folder-checked-out branch January 8, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants