Skip to content

fix: add CI/CD YAML validation hook for branch name escaping (Fixes #174) - #175

Open
laurentketterle-hub wants to merge 1 commit into
monk-io:mainfrom
laurentketterle-hub:fix/validate-cicd-yaml-174
Open

fix: add CI/CD YAML validation hook for branch name escaping (Fixes #174)#175
laurentketterle-hub wants to merge 1 commit into
monk-io:mainfrom
laurentketterle-hub:fix/validate-cicd-yaml-174

Conversation

@laurentketterle-hub

Copy link
Copy Markdown

Fix: CI/CD YAML Validation for Branch Name Escaping

Fixes #174

Problem

When monk.cicd.setup generates .github/workflows/deploy.yml with branch names containing quotes (e.g., feature"quoted), the resulting YAML is invalid. Setup reports success but GitHub cannot load the workflow.

Solution

This PR adds a PostToolUse hook that runs automatically after every monk.cicd.setup call:

  1. scripts/validate-cicd-yaml.sh (Linux/macOS)

    • Detects malformed branch name quotes in deploy.yml
    • Attempts auto-fix by replacing problematic patterns
    • Uses Python's yaml parser for deep validation when available
    • Creates timestamped backups before any fix
  2. scripts/validate-cicd-yaml.ps1 (Windows)

    • Equivalent PowerShell implementation
    • Same detection, warning, backup, and auto-fix logic
  3. Hooks registration — Matched to monk.cicd.setup in hooks.json PostToolUse

How it works

After monk.cicd.setup completes:

  • Hook checks .github/workflows/deploy.yml for malformed quoting
  • If valid → silent exit 0
  • If issues detected → warns user, creates backup, attempts auto-fix
  • Clear error messages reference this issue for context

Testing

  • Hook runs in <1 second for valid files
  • Timestamped backups prevent data loss
  • Graceful fallback when Python/PyYAML not available

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.

[Bug bounty] CI/CD setup reports success but generates invalid YAML for a valid quoted branch name

1 participant