Skip to content

Workflow Architecture & Cleanup Summary

This document summarizes the complete workflow architecture refactoring and cleanup that was performed to resolve GitHub Actions failures and improve maintainability.

  • Issue: Complex JavaScript embedded in YAML workflows caused syntax errors
  • Symptoms: Workflows failing with “workflow file issue” errors
  • Root Cause: YAML escaping issues with template variables and multiline strings
  • Issue: Global gitignore pattern **/.github prevented workflow files from being tracked
  • Symptoms: Required git add -f to commit workflow changes
  • Root Cause: Global gitignore overriding local repository needs
  • Issue: Legacy disabled workflows cluttering the project
  • Symptoms: Confusing directory structure with outdated files
  • Root Cause: Keeping backup files that were no longer needed

Before (Problematic):

- name: Complex auto-merge logic
uses: actions/github-script@v7
with:
script: |
// 200+ lines of JavaScript embedded in YAML
const prNumber = parseInt('${{ steps.get-pr.outputs.pr_number }}');
// Complex logic with template variables and escaping issues

After (Clean):

- name: Run auto-merge script
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_PAT || secrets.GITHUB_TOKEN }}
run: node .github/scripts/auto-merge.cjs

Benefits:

  • ✅ No YAML escaping issues
  • ✅ Proper syntax highlighting and error detection
  • ✅ Testable and debuggable scripts
  • ✅ Better version control and diff support

Before (Too Broad):

!.github/
!.github/**

After (Specific):

# GitHub Actions - override global gitignore that excludes .github directories
!.github/
!.github/workflows/
!.github/workflows/**
!.github/scripts/
!.github/scripts/**
# Ignore system files in .github but keep workflows and scripts
.github/.DS_Store

Benefits:

  • ✅ Overrides global gitignore effectively
  • ✅ Only includes what’s actually needed
  • ✅ Prevents accidental tracking of unwanted files
  • ✅ Standard Git workflow (no more git add -f)

Removed:

  • .github/workflows-disabled/ directory (3 files, ~473 lines)
  • All references to disabled workflows in documentation
  • Confusing backup files and legacy documentation

Result:

.github/
├── scripts/ # External workflow scripts
│ ├── auto-merge.cjs # Auto-merge logic for version sync PRs
│ └── sync-version.cjs # Version synchronization script
├── workflows/ # GitHub Actions workflows
│ ├── auto-merge-bot.yml # Auto-merge workflow (uses external script)
│ ├── pr-validation.yml # PR validation and testing
│ ├── release-publish.yml # Release publishing workflow
│ ├── smart-version-bump.yml # Smart version bumping
│ └── sync-package-version.yml # Package version sync (uses external script)
└── README.md # Clean, focused documentation

All workflows are now functioning correctly:

WorkflowStatusPurpose
pr-validation.yml✅ WorkingRuns tests, linting, builds on PRs
smart-version-bump.yml✅ WorkingAutomatic version bumping and releases
sync-package-version.yml✅ WorkingSyncs package.json with Git tags
auto-merge-bot.yml✅ WorkingAuto-merges version sync PRs
release-publish.yml✅ WorkingPublishes releases
  • Scripts are testable: Can run node .github/scripts/auto-merge.cjs locally
  • Better debugging: Standard Node.js debugging tools work
  • Clear separation: Logic in scripts, orchestration in workflows
  • No YAML syntax issues: Simple, clean workflow files
  • Proper error handling: Scripts can handle errors gracefully
  • Version control friendly: Better diffs and syntax highlighting
  • Standard Git workflow: No more git add -f required
  • Easy to modify: Change scripts without YAML escaping concerns
  • Clear documentation: Focused, up-to-date documentation
  • Embedded JavaScript in GitHub Actions workflows is fragile
  • YAML escaping issues are hard to debug
  • External scripts provide better maintainability
  • Global gitignore patterns can interfere with project needs
  • Specific negation patterns work better than broad includes
  • Always test gitignore changes with actual files
  • Keeping “backup” files in the repository creates confusion
  • Git history already preserves old implementations
  • Clean repository structure improves developer experience
  1. Create workflow YAML file in .github/workflows/
  2. For complex logic, create external script in .github/scripts/
  3. Keep workflows simple - just orchestration and script calls
  4. Test locally before committing
  1. Edit external scripts for logic changes
  2. Modify workflow YAML only for orchestration changes
  3. Scripts can be tested independently
  4. No YAML escaping concerns
  • Keep the specific .github/ patterns in place
  • Don’t revert to broad !.github/** pattern
  • Test new workflow files are tracked automatically
  • Use git check-ignore -v <file> to debug issues

The workflow architecture refactoring successfully resolved all GitHub Actions failures while establishing a maintainable, reliable foundation for future development. The external scripts approach provides better separation of concerns, easier debugging, and eliminates the YAML syntax issues that were causing problems.

The repository is now clean, focused, and ready for productive development with a robust CI/CD pipeline.