Repository navigation
Add fork sync workflow - #1
Open
wickedyoda wants to merge 1 commit into
Open
wickedyoda wants to merge 1 commit into
wickedyoda wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Branch handling, workflow preservation, concurrency, and command-injection vulnerabilities must be corrected.
7 open findings
Missing concurrency guard allows competing sync runs · New API-derived branch name enables shell command injection · New Force sync deletes fork-local workflows despite protection · New False protect_workflows input is overridden by default · New Routine sync does not overwrite fork-local commits as documented · New Upstream and fork default branches are conflated · New Failed merge without conflicts is incorrectly treated as successful · New
What changed in this PR
Adds a scheduled and manually triggered workflow for synchronizing the fork with its upstream repository.
Changes:
- Detects the upstream repository and default branch.
- Supports dry runs, forced synchronization, and workflow preservation.
- Generates a synchronization summary.
| File | Description |
|---|---|
.github/workflows/sync-fork.yml |
Implements upstream fork synchronization and reporting. |
🧠 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
+55
to
+61
| env: | ||
| OPT_DRY_RUN: ${{ inputs.dry_run || 'false' }} | ||
| OPT_PROTECT_WORKFLOWS: ${{ inputs.protect_workflows || 'true' }} | ||
| OPT_FORCE_SYNC: ${{ inputs.force_sync || 'false' }} | ||
| run: | | ||
| PRE_SHA="${{ steps.pre_sync.outputs.sha }}" | ||
| BRANCH="${{ steps.upstream.outputs.branch }}" |
Comment on lines
+70
to
+72
| if [ "$OPT_FORCE_SYNC" = "true" ]; then | ||
| git reset --hard "upstream/$BRANCH" | ||
| elif [ "$OPT_PROTECT_WORKFLOWS" = "true" ]; then |
| 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' }} |
|
|
||
| git remote add upstream "https://github.com/${{ steps.upstream.outputs.repo }}.git" | ||
| git fetch upstream | ||
| git checkout "$BRANCH" |
Comment on lines
+81
to
+84
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Adds
sync-fork.ymlworkflow to automatically sync this fork from its upstream parent repository daily at 04:00 UTC.The workflow:
.github/workflows/files (protect_workflows: true by default)Note: Any local changes outside
.github/workflows/will be overwritten during sync.