Skip to content

Sync WPCC Updates

Sync WPCC Updates #8

Workflow file for this run

# ============================================================
# WPCC Auto-Sync Workflow
# ============================================================
#
# PURPOSE:
# Automatically checks for updates to WP Code Check (WPCC) and
# pulls them into AI-DDTK via git subtree.
#
# SCHEDULE:
# Runs weekly on Sundays at 00:00 UTC
# Can also be triggered manually via workflow_dispatch
#
# FOR LLM AGENTS:
# - This workflow syncs tools/wp-code-check/ from upstream
# - It creates a PR for review (not auto-merge by default)
# - To change to auto-merge, set AUTO_MERGE to true
# - WPCC_REPO: Source repository for WP Code Check
# - WPCC_BRANCH: Branch to pull from (default: main)
#
# ============================================================
name: Sync WPCC Updates
on:
schedule:
# Runs at 00:00 UTC every Sunday
- cron: '0 0 * * 0'
workflow_dispatch:
inputs:
auto_merge:
description: 'Auto-merge without PR (use with caution)'
required: false
default: 'false'
type: choice
options:
- 'false'
- 'true'
env:
WPCC_REPO: https://github.com/Hypercart-Dev-Tools/WP-Code-Check.git
WPCC_BRANCH: main
WPCC_PREFIX: tools/wp-code-check
jobs:
check-and-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout AI-DDTK
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Check for WPCC updates
id: check-updates
run: |
echo "Fetching latest from WPCC..."
git fetch "${{ env.WPCC_REPO }}" "${{ env.WPCC_BRANCH }}" --depth=1
REMOTE_SHA=$(git rev-parse FETCH_HEAD)
echo "Remote WPCC SHA: $REMOTE_SHA"
# Get current subtree commit (from last subtree merge)
CURRENT_SHA=$(git log -1 --format="%H" -- "${{ env.WPCC_PREFIX }}")
echo "Current subtree SHA: $CURRENT_SHA"
# Check if there are differences
if git diff --quiet HEAD FETCH_HEAD -- ; then
echo "No updates available"
echo "has_updates=false" >> $GITHUB_OUTPUT
else
echo "Updates available!"
echo "has_updates=true" >> $GITHUB_OUTPUT
echo "remote_sha=$REMOTE_SHA" >> $GITHUB_OUTPUT
fi
- name: Pull WPCC updates
if: steps.check-updates.outputs.has_updates == 'true'
run: |
echo "Pulling WPCC updates via subtree..."
git subtree pull --prefix="${{ env.WPCC_PREFIX }}" \
"${{ env.WPCC_REPO }}" "${{ env.WPCC_BRANCH }}" \
--squash -m "chore: sync WPCC from upstream (auto-update)"
- name: Create Pull Request
if: steps.check-updates.outputs.has_updates == 'true' && github.event.inputs.auto_merge != 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: sync WPCC from upstream"
title: "🔄 Auto-sync: WPCC updates available"
body: |
## Automated WPCC Sync
This PR was automatically created by the weekly WPCC sync workflow.
### Changes
- Updated `tools/wp-code-check/` from upstream repository
- Source: ${{ env.WPCC_REPO }}
- Branch: ${{ env.WPCC_BRANCH }}
### Review Checklist
- [ ] Check WPCC changelog for breaking changes
- [ ] Verify `wpcc` command still works
- [ ] Run tests if applicable
---
*This PR was auto-generated by [sync-wpcc.yml](.github/workflows/sync-wpcc.yml)*
branch: auto-sync/wpcc-updates
delete-branch: true
labels: |
automated
dependencies
- name: Auto-merge (if enabled)
if: steps.check-updates.outputs.has_updates == 'true' && github.event.inputs.auto_merge == 'true'
run: |
echo "Auto-merge enabled, pushing directly to main..."
git push origin main
- name: Summary
run: |
if [ "${{ steps.check-updates.outputs.has_updates }}" == "true" ]; then
echo "✅ WPCC updates were found and processed"
else
echo "ℹ️ No WPCC updates available"
fi