Skip to content

Fix YAML anchor/alias generation in GitHub Actions workflow on triggers#7

Merged
chefgs merged 2 commits intomainfrom
copilot/fix-unknown-branch-ids
Mar 4, 2026
Merged

Fix YAML anchor/alias generation in GitHub Actions workflow on triggers#7
chefgs merged 2 commits intomainfrom
copilot/fix-unknown-branch-ids

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 4, 2026

PyYAML detects that the same branches list object is referenced in both push and pull_request trigger blocks and collapses them into an anchor/alias pair, producing invalid-for-GitHub-Actions output:

# Before — broken
'on':
  push:
    branches: &id001
    - main
  pull_request:
    branches: *id001
# After — correct
'on':
  push:
    branches:
    - main
  pull_request:
    branches:
    - main

Changes

  • cli/scaffold_gha.py — Added _NoAliasDumper(yaml.Dumper) that overrides ignore_aliases() to always return True; wired it into the yaml.dump() call that serialises the final workflow dict.
  • mcp_server/server.py — Same _NoAliasDumper pattern applied to the yaml.dump() call in generate_github_actions_workflow.
  • tests/test_comprehensive.py — Three regression tests asserting &id / *id are absent from serialised output and that both trigger blocks carry explicit branch lists (TestScaffoldGHA × 2, TestMCPServerGHA × 1).

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

PyYAML emitted anchor/alias pairs (&id001 / *id001) when the same
branches list object was reused in both push and pull_request triggers.
GitHub Actions does not support YAML aliases and the output was confusing.

- Add _NoAliasDumper (yaml.Dumper subclass with ignore_aliases=True) to
  cli/scaffold_gha.py and mcp_server/server.py
- Use the new dumper in both yaml.dump() call sites
- Add 3 new regression tests verifying no anchors/aliases in YAML output

Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unknown branch IDs in GitHub Actions workflow Fix YAML anchor/alias generation in GitHub Actions workflow on triggers Mar 4, 2026
@chefgs chefgs marked this pull request as ready for review March 4, 2026 20:03
@chefgs chefgs merged commit 8512dd4 into main Mar 4, 2026
4 checks passed
@chefgs chefgs deleted the copilot/fix-unknown-branch-ids branch March 4, 2026 20:15
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