Use this skill for repositories that mirror an upstream GitHub repo and preserve local .github workflow files with a safe-sync.yml workflow.
GITHUB_TOKEN before running the script.owner/repo.Inspect a mirror repo:
export GITHUB_TOKEN=...
./scripts/github_safe_sync.py status \
--owner grey00758 \
--repo ai-code-board \
--upstream grey0758/ai-code-board
Trigger a manual sync:
export GITHUB_TOKEN=...
./scripts/github_safe_sync.py dispatch \
--owner grey00758 \
--repo ai-code-board
Clean false-positive artifacts after a workflow fix:
export GITHUB_TOKEN=...
./scripts/github_safe_sync.py close-force-push-issues \
--owner grey00758 \
--repo ai-code-board
./scripts/github_safe_sync.py delete-backups \
--owner grey00758 \
--repo ai-code-board
status.dispatch.close-force-push-issues and delete-backups.status to verify the repo is clean.statuseffective_state=exact: Mirror and upstream branch heads are identical.effective_state=metadata-ahead: Mirror is only ahead by local .github-only commits. This is normally healthy for safe-sync mirrors.effective_state=behind: Upstream has newer commits and the mirror has not caught up yet.effective_state=local-ahead: Mirror has non-metadata commits that do not exist upstream. Inspect before forcing anything.effective_state=metadata-diverged: Histories differ, but the mirror-only side is metadata-only. This often means the sync workflow logic still needs review.effective_state=diverged: Mirror and upstream both changed in incompatible ways. Treat this as a real sync problem until proven otherwise.statusUse status first. It returns JSON with:
backup/ branchesIf the requested upstream branch does not exist, the script falls back to the upstream repo default branch.
dispatchUse dispatch to trigger workflow_dispatch on the sync workflow. Add --force-sync only when you intentionally want the workflow to ignore the normal no-op path.
close-force-push-issuesUse this only after you have confirmed the force-push alerts were false positives. It closes open issues whose title contains 检测到上游强制推送.
delete-backupsUse this only after you have confirmed the backup branches are noise. Start with --dry-run if you want to preview what would be removed.
backup/ branches until the mirror workflow is healthy and the backups are no longer needed.main; pass --branch or --upstream explicitly when the repo uses a different upstream default branch.status after every write operation.共 1 个版本