-
Notifications
You must be signed in to change notification settings - Fork 2
65 lines (51 loc) · 1.5 KB
/
Copy pathsync.yml
File metadata and controls
65 lines (51 loc) · 1.5 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
name: Sync data folder
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "data/**"
workflow_run:
workflows: ["Build Needed Java Mods"]
types:
- completed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Clone lyuwenhan.github.io
run: |
git clone https://x-access-token:${{ secrets.SYNC_PAT }}@github.com/lyuwenhan/lyuwenhan.github.io.git target
- name: Sync files
run: |
mkdir -p target/extensions/minecraft-java/data
rsync -av --delete data/ target/extensions/minecraft-java/data/
- name: Commit & Push
run: |
cd target
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
if git diff --cached --quiet; then
echo "No changes"
exit 0
fi
git commit -m "Auto sync data folder"
for i in 1 2 3 4 5; do
echo "Attempt $i to pull --rebase and push..."
git pull --rebase origin main && git push origin main && break
if [ "$i" -eq 5 ]; then
echo "Push failed after 5 attempts"
exit 1
fi
echo "Retrying in 5 seconds..."
sleep 5
done