Skip to content

Commit 61c17c1

Browse files
authored
Create sync-main.yml
Create sync-main.yml to automatic sync for main branch from llvm-project to llvm
1 parent c7447f7 commit 61c17c1

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/sync-main.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: automatic sync main branch from llvm-project to llvm test on sycl
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '*/10 * * * *'
7+
jobs:
8+
check:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
# persist-credentials: false allows us to use our own credentials for
15+
# pushing to the repository. Otherwise, the default github actions token
16+
# is used.
17+
persist-credentials: false
18+
fetch-depth: 0
19+
path: src
20+
- name: Sync
21+
env:
22+
BRANCH: main
23+
SYNC_REPO: https://github.com/llvm/llvm-project
24+
LLVMBOT_TOKEN: ${{ secrets.LLVM_MAIN_SYNC_BBSYCL_TOKEN }}
25+
run: |
26+
cd $GITHUB_WORKSPACE/src
27+
branch_exist=`git ls-remote --heads origin $BRANCH | wc -l`
28+
if [ $branch_exist -ne 0 ]; then
29+
git checkout $BRANCH
30+
git pull --ff --ff-only $SYNC_REPO $BRANCH
31+
if [ $? -ne 0 ]; then
32+
echo "failed to pull from $SYNC_REPO $BRANCH, abort"
33+
exit 1
34+
fi
35+
git_status=`git rev-list --count --left-right origin/$BRANCH...$BRANCH`
36+
if [ "0 0" == "$git_status" ] ; then
37+
echo "no change, skip"
38+
elif [[ "$git_status" = 0* ]] ; then
39+
git push https://[email protected]/${{ github.repository }} ${BRANCH}
40+
else
41+
echo "$BRANCH branch invalid state"
42+
exit 1
43+
fi
44+
else
45+
git remote add upstream $SYNC_REPO
46+
git fetch upstream
47+
git checkout -B $BRANCH upstream/$BRANCH
48+
git push https://[email protected]/${{ github.repository }} ${BRANCH}
49+
fi
50+
echo "sync finished"

0 commit comments

Comments
 (0)