forked from nkanaev/yarr
-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (56 loc) · 1.85 KB
/
sync.yml
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
# Synchronize this repository with its upstream source (nkanaev/yarre)
name: sync
on:
# Run every Saturday at 00:00 UTC
schedule:
- cron: '0 0 * * 6'
# Run when manually triggered
workflow_dispatch:
jobs:
synchronize:
name: Synchronize with upstream
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
# Checkout downstream (This repository) twice, once for the old state and once for the new state
- name: Checkout downstream (Old)
uses: actions/checkout@v4
with:
fetch-depth: 0
path: old
- name: Checkout downstream (New)
uses: actions/checkout@v4
with:
fetch-depth: 0
path: new
# Authenticate to Git
- name: Authenticate to Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git config --global user.password "${{ github.token }}"
# Merge upstream (Will overwrite all changes)
- name: Merge upstream
working-directory: new
run: |
git config pull.rebase false
git remote add upstream https://github.com/nkanaev/yarr.git
git pull --strategy-option theirs --no-edit upstream master
# Merge downstream (Will restore certain files)
- name: Merge downstream
run: |
for file in .github Dockerfile entrypoint.sh readme.md; do
# Remove the new file
rm -rf new/$file
# Copy the old file
cp -rf old/$file new/$file
done
# Commit changes
- name: Commit changes
working-directory: new
continue-on-error: true
run: git commit -am "Synchronize with upstream"
# Push changes
- name: Push changes
working-directory: new
run: git push origin main