-
Notifications
You must be signed in to change notification settings - Fork 1.1k
48 lines (42 loc) · 1.46 KB
/
manual-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
name: Sync with ppy:master
on:
workflow_dispatch:
inputs:
backup:
default: false
description: Create a backup of the selected branch
required: true
type: boolean
overwrite:
default: false
description: Overwrite all history of the selected branch
required: true
type: boolean
jobs:
sync:
name: Sync with ppy:master
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update branches
run: |
branch_name="$(git branch --show-current)"
backup_branch_name="$branch_name-backup"
if ${{ inputs.backup }}; then
printf '::notice::Backing up "%s" to "%s"\n' "$branch_name" "$backup_branch_name"
git push origin "HEAD:$backup_branch_name"
fi
git remote add upstream https://github.com/ppy/osu-wiki
git fetch upstream master
if ${{ inputs.overwrite }}; then
printf '::warning::Overwriting "%s"\n' "$branch_name"
git push --force origin "FETCH_HEAD:$branch_name"
else
printf '::notice::Merging into "%s"\n' "$branch_name"
git config user.name '${{ github.actor }}'
git config user.email '${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com'
git merge -m 'Merge master' FETCH_HEAD
git push origin "$branch_name"
fi