-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (68 loc) · 2.55 KB
/
sync.yml
File metadata and controls
81 lines (68 loc) · 2.55 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
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Sync React Mirror
on:
schedule:
# Run every 30 minutes
- cron: '*/30 * * * *'
workflow_dispatch:
# Allow manual trigger
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout sync repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Clone react-mirror
run: |
git clone https://x-access-token:${{ secrets.MIRROR_PAT }}@github.com/greptileai/react-mirror.git mirror
cd mirror
git remote add upstream https://github.com/facebook/react.git
git fetch upstream --tags --prune
- name: Configure Git
working-directory: mirror
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Sync all branches
working-directory: mirror
run: |
# Sync all branches from upstream
git fetch upstream '+refs/heads/*:refs/remotes/upstream/*' --prune
# Push each upstream branch to origin
for branch in $(git branch -r | grep 'upstream/' | grep -v HEAD | sed 's|upstream/||'); do
echo "Syncing branch: $branch"
git checkout -B "$branch" "upstream/$branch"
git push origin "$branch" --force
done
# Return to main
git checkout main
- name: Sync tags
working-directory: mirror
run: |
git push origin --tags --force
- name: Sync labels
env:
GH_TOKEN: ${{ secrets.MIRROR_PAT }}
run: |
echo "Syncing labels from upstream..."
gh label list --repo facebook/react --json name,color,description --limit 200 | \
jq -c '.[]' | while read label; do
name=$(echo "$label" | jq -r '.name')
color=$(echo "$label" | jq -r '.color')
desc=$(echo "$label" | jq -r '.description // empty')
if [ -n "$desc" ]; then
gh label create "$name" --repo greptileai/react-mirror --color "$color" --description "$desc" --force 2>/dev/null || true
else
gh label create "$name" --repo greptileai/react-mirror --color "$color" --force 2>/dev/null || true
fi
done
echo "Labels synced."
- name: Sync PRs
working-directory: mirror
env:
GH_TOKEN: ${{ secrets.MIRROR_PAT }}
run: |
python ${{ github.workspace }}/scripts/sync_mirror.py