forked from PrismLauncher/PrismLauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (51 loc) · 2.07 KB
/
rebase.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
name: Rebase Upstream
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
- name: Use PAT for origin
run: |
GITHUB_TOKEN=${{ secrets.GH_PAT }}
old_origin=$(git remote get-url origin)
git remote set-url origin "${old_origin/https:\/\//https:\/\/$GITHUB_TOKEN@}"
shell: bash
- name: Rebase upstream changes
id: rebase
run: |
function commit_on_change {
git status --porcelain | grep -q . && git add -A && git commit -m "$1"
}
# Configure committer identity
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
# Configure merge driver
git config --global merge.ours.driver true
attributes="README.md merge=ours\n.github/workflows/** merge=ours"
grep -q "$attributes" .gitattributes || echo "$attributes" >> .gitattributes
commit_on_change "chore(gitattributes): reapply merge driver"
# Fetch changes and rebase
git remote add upstream https://github.com/PrismLauncher/PrismLauncher.git
git fetch upstream develop
git rebase upstream/develop -X theirs
# Remove actions triggers we don't need
rm .github/workflows/trigger_builds.yml .github/workflows/trigger_release.yml
commit_on_change "chore(actions): remove trigger workflows"
# Push and allow triggering release if there were changes
if ! git diff --quiet origin/develop -- . ':(exclude).gitattributes' ':(exclude).github/workflows/'; then
echo "has_changed=true" >> $GITHUB_OUTPUT
git push --force-with-lease
fi
- name: Trigger nightly release
if: ${{ steps.rebase.outputs.has_changed }}
uses: peter-evans/repository-dispatch@v3
with:
repository: 0x5eal/prismlauncher-nightlies
event-type: release