name: Sync with Upstream BMAD and Re-apply QA Integration on: schedule: - cron: '0 0 * * 0' # Weekly on Sunday at midnight UTC workflow_dispatch: # Allow manual triggering permissions: contents: write pull-requests: write jobs: sync-and-integrate: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 # Fetch full history for better merging - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: Configure git run: | git config --global user.name 'BMAD QA Integration Bot' git config --global user.email 'noreply@bmad-qa.local' - name: Add upstream remote run: | git remote add upstream https://github.com/bmad-code-org/BMAD-METHOD.git || true git fetch upstream - name: Check for upstream changes id: check_changes run: | # Get the current HEAD and upstream HEAD CURRENT_HEAD=$(git rev-parse HEAD) UPSTREAM_HEAD=$(git rev-parse upstream/main) if [ "$CURRENT_HEAD" = "$UPSTREAM_HEAD" ]; then echo "No upstream changes detected" echo "has_changes=false" >> $GITHUB_OUTPUT else echo "Upstream changes detected" echo "has_changes=true" >> $GITHUB_OUTPUT # Get list of changed files for the PR description git log --oneline $CURRENT_HEAD..$UPSTREAM_HEAD > /tmp/upstream_changes.txt echo "UPSTREAM_CHANGES<> $GITHUB_OUTPUT cat /tmp/upstream_changes.txt >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi - name: Create integration branch if: steps.check_changes.outputs.has_changes == 'true' run: | BRANCH_NAME="upstream-sync-$(date +%Y%m%d-%H%M%S)" echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV git checkout -b $BRANCH_NAME - name: Backup QA integration files if: steps.check_changes.outputs.has_changes == 'true' run: | # Create backup of our custom files that might conflict mkdir -p /tmp/qa-backup # Backup expansion pack cp -r expansion-packs/bmad-production-qa /tmp/qa-backup/ || true # Backup our enhanced tasks cp bmad-core/tasks/create-next-story-with-qa.md /tmp/qa-backup/ || true # Backup any modified core files cp -r .github /tmp/qa-backup/ || true echo "QA integration files backed up" - name: Merge upstream changes if: steps.check_changes.outputs.has_changes == 'true' run: | # Attempt to merge upstream changes git merge upstream/main --no-edit || { echo "Merge conflicts detected. Manual intervention required." # Create a summary of conflicts echo "## Merge Conflicts Detected" > /tmp/conflict_summary.md echo "" >> /tmp/conflict_summary.md echo "The following files have conflicts:" >> /tmp/conflict_summary.md git diff --name-only --diff-filter=U >> /tmp/conflict_summary.md # For now, abort the merge and create an issue git merge --abort exit 1 } - name: Restore QA integration if: steps.check_changes.outputs.has_changes == 'true' run: | # Restore our expansion pack (should never conflict) cp -r /tmp/qa-backup/bmad-production-qa expansion-packs/ || true # Restore our enhanced task cp /tmp/qa-backup/create-next-story-with-qa.md bmad-core/tasks/ || true # Restore workflows cp -r /tmp/qa-backup/.github . || true echo "QA integration restored" - name: Install dependencies and validate if: steps.check_changes.outputs.has_changes == 'true' run: | npm ci # Run validation if available npm run validate || echo "No validation script found" # Test that our expansion pack is valid if [ -f "tools/cli.js" ]; then node tools/cli.js validate || echo "BMAD validation not available" fi - name: Commit integration if: steps.check_changes.outputs.has_changes == 'true' run: | git add . git commit -m "Sync with upstream BMAD and restore QA integration Upstream changes: ${{ steps.check_changes.outputs.UPSTREAM_CHANGES }} QA Integration maintained: - bmad-production-qa expansion pack - Enhanced story creation with QA - Production QA workflows - Testing framework setup 🤖 Auto-generated by sync workflow" - name: Push integration branch if: steps.check_changes.outputs.has_changes == 'true' run: | git push origin $BRANCH_NAME - name: Create Pull Request if: steps.check_changes.outputs.has_changes == 'true' uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ env.BRANCH_NAME }} title: "🔄 Sync with upstream BMAD (Auto-generated)" body: | ## Upstream BMAD Sync This PR automatically syncs changes from the upstream BMAD repository and maintains our QA integration. ### Upstream Changes ``` ${{ steps.check_changes.outputs.UPSTREAM_CHANGES }} ``` ### QA Integration Status - ✅ `bmad-production-qa` expansion pack preserved - ✅ Enhanced story creation task maintained - ✅ Production QA workflows intact - ✅ GitHub workflows preserved ### Review Checklist - [ ] Verify no conflicts with core BMAD functionality - [ ] Test QA agents work correctly - [ ] Validate story creation with QA integration - [ ] Confirm all expansion pack features working ### Auto-merge Criteria This PR can be auto-merged if: - All CI checks pass - No merge conflicts detected - QA integration validation successful --- 🤖 **Auto-generated** by upstream sync workflow 📅 **Created**: $(date -u +"%Y-%m-%d %H:%M:%S UTC") labels: | upstream-sync automated qa-integration draft: false - name: Create conflict issue if: failure() && steps.check_changes.outputs.has_changes == 'true' uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} title: "🚨 Manual intervention required: Upstream sync conflicts" body: | ## Merge Conflicts Detected The automated sync with upstream BMAD has detected merge conflicts that require manual resolution. ### What happened? - Attempted to merge changes from upstream BMAD repository - Merge conflicts detected in core files - Automatic resolution failed ### Next Steps 1. Manually resolve conflicts in conflicted files 2. Ensure QA integration is preserved 3. Test all QA functionality after resolution 4. Update this issue when resolved ### Files likely affected Check these areas for conflicts: - `bmad-core/` directory changes - `package.json` dependency updates - Core workflow modifications --- 🤖 **Auto-generated** by upstream sync workflow 📅 **Created**: $(date -u +"%Y-%m-%d %H:%M:%S UTC") labels: | upstream-sync conflicts manual-intervention-required priority-high - name: Notify on success if: success() && steps.check_changes.outputs.has_changes == 'true' run: | echo "✅ Successfully synced with upstream BMAD and maintained QA integration" echo "📋 Pull request created for review" - name: Notify on no changes if: steps.check_changes.outputs.has_changes == 'false' run: | echo "â„šī¸ No upstream changes detected. Repository is up to date."