forked from jhlywa/chess.js
-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (39 loc) · 1.31 KB
/
Copy pathauto-sync.yml
File metadata and controls
48 lines (39 loc) · 1.31 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
name: Auto Sync with Upstream
on:
schedule:
- cron: '0 0 * * *' # daily
workflow_dispatch:
env:
SYNC_BRANCH: master # Change to main if your repo uses main
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up git user
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Add upstream remote and fetch
run: |
git remote | grep -q upstream || git remote add upstream https://github.com/jhlywa/chess.js.git
git fetch upstream
- name: Show pre-merge status
run: git status
- name: Merge upstream changes
run: |
git checkout ${{ env.SYNC_BRANCH }}
git merge upstream/${{ env.SYNC_BRANCH }} --allow-unrelated-histories || true
- name: Show post-merge status
run: git status
- name: Push changes if any
env:
GH_TOKEN: ${{ secrets.AUTO_SYNC }}
run: |
if [ -n "$(git status --porcelain)" ]; then
git push https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }} ${{ env.SYNC_BRANCH }}
else
echo "No changes to push."
fi