forked from ml-explore/mlx-swift
-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (58 loc) · 2.75 KB
/
upstream_sync.yml
File metadata and controls
68 lines (58 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Upstream Sync
on:
schedule:
- cron: '0 */4 * * *' # Run every 4 hours
workflow_dispatch: # Allow manual triggering
jobs:
check-and-create-pr:
name: Check Upstream and Create PR
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to fetch all history for commit comparison
token: ${{ secrets.SWIFTLM_PR_TOKEN || secrets.GITHUB_TOKEN }}
- name: Check for upstream changes and set up branch
id: check_upstream
run: |
# Add the upstream repository
git remote add upstream https://github.com/ml-explore/mlx-swift.git
git fetch upstream main
# Check how many commits upstream is ahead of our local main
AHEAD=$(git rev-list --count HEAD..upstream/main)
echo "Upstream is $AHEAD commits ahead."
if [ "$AHEAD" -gt 0 ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
BRANCH_NAME="sync/upstream-latest"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
# Checkout upstream main into the static sync branch (force reset if it exists)
git checkout -B $BRANCH_NAME upstream/main
git push --force origin $BRANCH_NAME
else
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No new commits to sync."
fi
- name: Create or Update Pull Request
if: steps.check_upstream.outputs.has_changes == 'true'
run: |
# Check if a PR already exists for this branch
PR_EXISTS=$(gh pr list HEAD --head ${{ steps.check_upstream.outputs.branch_name }} --json number --jq 'length')
if [ "$PR_EXISTS" -eq "0" ]; then
gh pr create \
--title "🔄 Auto-Sync: Upstream changes from ml-explore/mlx-swift" \
--body "Automated PR to sync the latest changes from upstream \`ml-explore/mlx-swift\`'s \`main\` branch.
### Merge Warnings
* **Do NOT blind merge!** This repo contains custom SharpAI out-of-core SSD features.
* Refer to the \`UPSTREAM_MERGE_PLAN.md\` file locally to check standard SharpAI metal optimization discrepancies.
* Do **not** overwrite the submodule branch pointers under \`Package.swift\` without consultation." \
--base main \
--head ${{ steps.check_upstream.outputs.branch_name }}
else
echo "PR already exists. Force pushing to the branch updated the PR automatically."
fi
env:
GH_TOKEN: ${{ secrets.SWIFTLM_PR_TOKEN || secrets.GITHUB_TOKEN }}