Skip to content

Add fork sync workflow - #1

Open
wickedyoda wants to merge 1 commit into
mainfrom
add/sync-fork-workflow
Open

wickedyoda wants to merge 1 commit into
mainfrom
add/sync-fork-workflow

Conversation

@wickedyoda

Copy link
Copy Markdown

Adds sync-fork.yml workflow to automatically sync this fork from its upstream parent repository daily at 04:00 UTC.

The workflow:

  • Auto-detects the upstream parent repo via GitHub API
  • Fetches and merges upstream changes into the fork's default branch
  • Preserves local .github/workflows/ files (protect_workflows: true by default)
  • Force-pushes the merged result (overwrites fork history with upstream)

Note: Any local changes outside .github/workflows/ will be overwritten during sync.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 15:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Shell-injection risks and several synchronization correctness issues must be resolved.

7 open findings
What changed in this PR

Adds automated daily and manual synchronization with the fork’s upstream repository.

Changes:

  • Detects and fetches the upstream default branch.
  • Supports dry-run, workflow protection, and forced synchronization.
  • Publishes a synchronization summary.
File Description
.github/​workflows/​sync-fork.yml Defines the fork synchronization workflow.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

type: boolean
default: false

jobs:
Comment on lines +58 to +61
OPT_FORCE_SYNC: ${{ inputs.force_sync || 'false' }}
run: |
PRE_SHA="${{ steps.pre_sync.outputs.sha }}"
BRANCH="${{ steps.upstream.outputs.branch }}"
id: sync
env:
OPT_DRY_RUN: ${{ inputs.dry_run || 'false' }}
OPT_PROTECT_WORKFLOWS: ${{ inputs.protect_workflows || 'true' }}
env:
OPT_DRY_RUN: ${{ inputs.dry_run || 'false' }}
OPT_PROTECT_WORKFLOWS: ${{ inputs.protect_workflows || 'true' }}
OPT_FORCE_SYNC: ${{ inputs.force_sync || 'false' }}
Comment on lines +70 to +72
if [ "$OPT_FORCE_SYNC" = "true" ]; then
git reset --hard "upstream/$BRANCH"
elif [ "$OPT_PROTECT_WORKFLOWS" = "true" ]; then
Comment on lines +80 to +89
# If merge failed, only continue when conflicts are limited to workflows.
if [ "$MERGE_EXIT" -ne 0 ]; then
CONFLICTS=$(git diff --name-only --diff-filter=U)
NON_WORKFLOW_CONFLICTS=$(echo "$CONFLICTS" | grep -vE '^\.github/workflows/' || true)
if [ -n "$NON_WORKFLOW_CONFLICTS" ]; then
echo "Conflicts outside .github/workflows detected:" >&2
echo "$NON_WORKFLOW_CONFLICTS" >&2
exit 1
fi
fi
Comment on lines +152 to +153
REPO="${{ steps.upstream.outputs.repo }}"
echo "| [\`$sha\`](https://github.com/$REPO/commit/$sha) | $msg |" >> "$GITHUB_STEP_SUMMARY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants