-
Notifications
You must be signed in to change notification settings - Fork 8
101 lines (89 loc) · 2.66 KB
/
github_sync.yml
File metadata and controls
101 lines (89 loc) · 2.66 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Repo sync
on:
schedule:
# 3시간마다 실행
- cron: '0 */3 * * *'
workflow_dispatch:
inputs:
source_branch:
description: 'Source branch to sync from'
required: true
default: 'devel'
destination_branch:
description: 'Destination branch to sync to'
required: true
default: 'devel'
jobs:
repo-sync:
runs-on: [ code-linux, code-large ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.source_branch || 'devel' }}
fetch-depth: 0
- name: Configure git
run: git config --global user.name "github-action[bot]"
- name: Force push to public github
env:
PUBLIC_PAT: ${{ secrets.PAT_TOKEN }}
run: |
SRC="${{ github.event.inputs.source_branch || 'devel' }}"
DEST="${{ github.event.inputs.destination_branch || 'devel' }}"
REMOTE_URL="https://rabbitfor:${{ secrets.PAT_TOKEN }}@github.com/dalihub/dali-ui.git"
MAX_RETRIES=3
RETRY_COUNT=0
SUCCESS=false
git remote add public "$REMOTE_URL"
until [ $RETRY_COUNT -ge $MAX_RETRIES ]
do
if git push public "$SRC:$DEST" --force; then
echo "Succeed"
SUCCESS=true
break
else
RETRY_COUNT=$((RETRY_COUNT+1))
echo "Retry after 5 sec..."
sleep 5
fi
done
if [ "$SUCCESS" = false ]; then
echo "Failed to push dalihub repo"
exit 1
fi
- name: Checkout
uses: actions/checkout@v3
with:
ref: wiki
fetch-depth: 0
- name: Sync wiki
env:
PUBLIC_PAT: ${{ secrets.PAT_TOKEN }}
run: |
SRC="wiki"
DEST="wiki"
MAX_RETRIES=3
RETRY_COUNT=0
SUCCESS=false
until [ $RETRY_COUNT -ge $MAX_RETRIES ]
do
if git push public "$SRC:$DEST" --force; then
echo "Succeed"
SUCCESS=true
break
else
RETRY_COUNT=$((RETRY_COUNT+1))
echo "Retry after 5 sec..."
sleep 5
fi
done
if [ "$SUCCESS" = false ]; then
echo "Failed to push dalihub repo"
exit 1
fi
- name: Sync tags
env:
PUBLIC_PAT: ${{ secrets.PAT_TOKEN }}
run: |
REMOTE_URL="https://rabbitfor:${{ secrets.PAT_TOKEN }}@github.com/dalihub/dali-ui.git"
git push "$REMOTE_URL" --tags --force