Skip to content

Update sync-standards-keep.json #139

Update sync-standards-keep.json

Update sync-standards-keep.json #139

name: ♻️ GitHub User Sync
on:
push:
branches: [ main, master ]
paths:
# --- Workflow files
- ".github/workflows/github-user-sync.yml"
# --- Heartbeat
- "admin/.sync-heartbeat"
# --- Template folders to watch
- ".github/**"
# --- Source sync files
- "admin/*.sh"
- "admin/*.json"
- "tools/*"
# --- Governance documents
- "CODE_OF_CONDUCT.md"
- "CONTRIBUTING.md"
- "CONTRIBUTING.project.md"
- "LICENSE"
- "NOTICE_PRIVATE.md"
- "SECURITY.md"
# --- Editor files
- ".editorconfig"
- "format-code.ps1"
- "format-code.sh"
workflow_call:
inputs:
max_jobs:
description: "Maximum concurrent repos to sync"
required: false
default: 4
type: number
workflow_dispatch:
inputs:
max_jobs:
description: "Maximum concurrent repos to sync"
required: false
default: 4
type: number
jobs:
# ----------------------------------------
# 🧠 User Sync
# ----------------------------------------
user-sync:
# Only run for user-owned repos, and only when this is the .github hub
if: ${{ github.event.repository.owner.type != 'Organization' && endsWith(github.repository, '/.github') }}
# (Optional even stricter: && github.repository_owner == 'TheKrush')
name: 🧠 User Sync (GitHub)
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: 🔎 Repo info (debug)
run: |
echo "Repository: ${{ github.repository }}"
echo "Owner: ${{ github.repository_owner }}"
echo "Owner type: ${{ github.event.repository.owner.type }}"
echo "Runner: $RUNNER_NAME"
echo "Runner OS: $RUNNER_OS"
- name: 🧰 Minimal Checkout for Local Actions
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/actions
.github/scripts
fetch-depth: 1
- name: ⚙️ Configure Git
shell: bash
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global credential.helper store
echo "https://x-access-token:${{ secrets.GH_TOKEN }}@github.com" > ~/.git-credentials
- name: 🧾 Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
token: ${{ secrets.GH_TOKEN }}
- name: ⚙️ Install tools
run: |
sudo apt-get update
sudo apt-get install -y git gh jq perl
echo "${{ secrets.GH_TOKEN }}" | gh auth login --with-token
gh auth status -t
- name: 🔮 Run User Sync
shell: bash
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
# workflow_dispatch → github.event.inputs.max_jobs
# workflow_call → inputs.max_jobs
# push → falls back to 4
MAX_JOBS: ${{ github.event.inputs.max_jobs || inputs.max_jobs || 4 }}
run: |
cd admin
set -o pipefail
find . -type f -name "*.sh" -exec sed -i 's/\r$//' {} \;
chmod +x *.sh
start=$(date +%s)
bash sync-core.sh | tee ../sync-output.txt
end=$(date +%s)
echo "⏱️ Sync duration: $(( (end - start) / 60 )) minutes"
- name: 📦 Upload Logs
uses: actions/upload-artifact@v4
if: always()
with:
name: user-sync-logs
path: admin/logs/
retention-days: 30
- name: 📄 Show Summary
if: always()
shell: bash
run: |
echo "### Sync Completed $(date -u)" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Repository | Status | Standards |" >> "$GITHUB_STEP_SUMMARY"
echo "|-------------|--------|-----------|" >> "$GITHUB_STEP_SUMMARY"
shopt -s nullglob
failed_any=0
total_clobbers=0
for log in admin/logs/*.log; do
repo=$(basename "$log" .log)
# Status detection
if grep -iq "failed" "$log"; then
status="❌ Failed"
failed_any=1
else
status="✅ Success"
fi
# Standards clobber detection (from sync-standards.sh logs)
clobber_count=$(grep -c '\[CLOBBER\]' "$log" || true)
if [[ "$clobber_count" -gt 0 ]]; then
standards="⚠️ ${clobber_count} clobber(s)"
total_clobbers=$(( total_clobbers + clobber_count ))
else
standards="—"
fi
echo "| $repo | $status | $standards |" >> "$GITHUB_STEP_SUMMARY"
done
shopt -u nullglob
if [[ $total_clobbers -gt 0 ]]; then
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "> Standards sync clobbered previously changed paths in this run (**$total_clobbers** total clobber(s) across all repos). See per-repo logs and commits for details." >> "$GITHUB_STEP_SUMMARY"
fi
if [[ $failed_any -ne 0 ]]; then
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "> One or more repositories failed to sync." >> "$GITHUB_STEP_SUMMARY"
# Make the job fail so the workflow shows red
exit 1
fi
- name: 🧹 Cleanup Runner
if: always()
uses: ./.github/actions/cleanup-runner