$npx -y skills add opendatahub-io/ai-helpers --skill github-sync-upstreamSync code from an upstream GitHub repository into a target fork (e.g., opendatahub-io midstream). Detects remotes from the current repo, or clones fresh if run from outside. Fetches upstream, merges into a sync branch, restores protected files, resolves conflicts, and opens a PR
| 1 | # Sync Upstream |
| 2 | |
| 3 | Merge upstream commits into a sync branch on the user's fork and open a |
| 4 | PR to the target repo. See `references/workflow.md` for exact script |
| 5 | invocations, exit-code handling, and the summary template. |
| 6 | |
| 7 | **Commit SHA (optional):** `$ARGUMENTS` |
| 8 | |
| 9 | ## Step 1: Determine Working Context |
| 10 | |
| 11 | ```bash |
| 12 | REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) || REPO_ROOT="" |
| 13 | ``` |
| 14 | |
| 15 | If `REPO_ROOT` is non-empty, run `scripts/detect-remotes.sh --repo "${REPO_ROOT}"` |
| 16 | and ask via `AskUserQuestion` whether this is the correct repo. |
| 17 | If yes → Step 2A. If no or not in a repo → Step 2B. |
| 18 | |
| 19 | ## Step 2A: In-Repo Setup |
| 20 | |
| 21 | Pre-fill upstream/target from detect-remotes output. Ask via |
| 22 | `AskUserQuestion` to confirm: upstream repo, target repo, branches |
| 23 | (default `main`). Run `scripts/setup-remotes.sh`, parse `UPSTREAM_REMOTE` and |
| 24 | `TARGET_REMOTE`. Save `ORIGINAL_BRANCH` from current HEAD. |
| 25 | |
| 26 | ## Step 2B: Clone From Scratch |
| 27 | |
| 28 | Ask for upstream repo, target repo, and branches. If the user has a |
| 29 | local clone, use its path and continue as Step 2A. If not, ask if they |
| 30 | have a GitHub fork — run `scripts/clone-fork.sh` then `scripts/setup-remotes.sh`. If |
| 31 | no fork exists, ask them to create one and re-run. **Stop.** |
| 32 | |
| 33 | Save `ORIGINAL_BRANCH` from current HEAD. |
| 34 | |
| 35 | ## Step 3: Protected Files |
| 36 | |
| 37 | Protected files keep the target version, discarding upstream changes. |
| 38 | Ask via `AskUserQuestion` for glob patterns to protect (or none). |
| 39 | Suggest common examples: `OWNERS*`, `.tekton/*.yaml`, |
| 40 | `Dockerfile*konflux`. |
| 41 | |
| 42 | ## Step 4: Pre-flight Check |
| 43 | |
| 44 | Verify `origin` does not point to upstream or target. If it does, tell |
| 45 | the user to set origin to their personal fork and stop. |
| 46 | |
| 47 | ## Step 5: Merge |
| 48 | |
| 49 | Run `scripts/sync-merge.sh`. Handle exit codes 0 (success), 1 (conflicts), and |
| 50 | 3 (duplicate branch) as described in `references/workflow.md`. |
| 51 | |
| 52 | ## Step 6: Push and Open PR |
| 53 | |
| 54 | Show PR summary and ask via `AskUserQuestion`: open a PR or just push? |
| 55 | If confirmed, run `scripts/open-pr.sh`. |
| 56 | |
| 57 | ## Step 7: Cleanup and Summary |
| 58 | |
| 59 | Check out `ORIGINAL_BRANCH`. For Path B clones, inform the user of the |
| 60 | temp directory. Display the summary per `references/workflow.md`. |