Skip to content

Add fallback resolution for workflows in .github/workflows/ directory#1762

Merged
pelikhan merged 3 commits into
mainfrom
copilot/update-add-command-workflow-resolve
Oct 15, 2025
Merged

Add fallback resolution for workflows in .github/workflows/ directory#1762
pelikhan merged 3 commits into
mainfrom
copilot/update-add-command-workflow-resolve

Conversation

Copilot AI commented Oct 15, 2025

Copy link
Copy Markdown
Contributor

Problem

The add command was unable to resolve workflow files stored in .github/workflows/ when using the three-part specification format. For example:

gh aw add githubnext/aw-wsg/3_15-ensure-that-your-code-is-secure

This command would fail because it only looked for workflows at:

<package>/githubnext/aw-wsg/workflows/3_15-ensure-that-your-code-is-secure.md

But the actual file was located at:

<package>/githubnext/aw-wsg/.github/workflows/3_15-ensure-that-your-code-is-secure.md

Solution

This PR implements a fallback mechanism in the findWorkflowInPackageForRepo function. When a workflow path starting with workflows/ is not found at the initial location, the function now automatically tries .github/workflows/ as a fallback.

The fallback logic:

  1. Attempts to read from the original workflows/ path
  2. If that fails and the path starts with workflows/, extracts the filename and tries .github/workflows/
  3. Returns an error only if both attempts fail

Example

After this change, the following command now works correctly:

gh aw add githubnext/aw-wsg/3_15-ensure-that-your-code-is-secure

It successfully resolves to @githubnext/aw-wsg/.github/workflows/3_15-ensure-that-your-code-is-secure.md.

Testing

Added comprehensive test coverage with 4 new tests:

  • Verifies fallback behavior when only .github/workflows/ path exists
  • Verifies original path is prioritized when it exists
  • Verifies proper error handling when neither path exists
  • Verifies non-workflows/ paths don't trigger fallback

All existing tests continue to pass, ensuring backward compatibility.

Backward Compatibility

This change is fully backward compatible:

  • If a workflow exists at workflows/, it will be used (no behavior change)
  • The fallback only activates when the original path doesn't exist
  • Custom paths (not starting with workflows/) are unaffected
Original prompt

Update the "add" command to try to resolve the agentic workflow file from the ".github/workflows" folder if it does not find it immediately using the full relative path.

So this command should work:

gh aw add githubnext/aw-wsg/3_15-ensure-that-your-code-is-secure 

and resolve to @githubnext/aw-wsg/files/.github/workflows/3_15-ensure-that-your-code-is-secure.md


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

- Modified findWorkflowInPackageForRepo to try .github/workflows/ when workflows/ fails
- Added comprehensive tests for fallback behavior
- All existing tests pass

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review October 15, 2025 19:41
@github-actions

Copy link
Copy Markdown
Contributor

Agentic Changeset Generator triggered by this pull request

Copilot AI changed the title [WIP] Update add command to resolve agentic workflow file Add fallback resolution for workflows in .github/workflows/ directory Oct 15, 2025
Copilot AI requested a review from pelikhan October 15, 2025 19:44
@pelikhan
pelikhan merged commit a4e9e23 into main Oct 15, 2025
4 checks passed
@pelikhan
pelikhan deleted the copilot/update-add-command-workflow-resolve branch October 15, 2025 19:45
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