This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (80 loc) · 3.23 KB
/
upstream.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Edited https://github.com/PrismarineTeam/PrismarineManager
name: Scheduled Upstream (1.19)
on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: "*/20 * * * *"
env:
paper: PaperMC/Paper # Paper Repo
pris: KPaperMC/KPaper # Publish Repo
papb: master # Paper Branch
prib: main # Publish Branch
jobs:
check:
name: Check Upstreams
if: "!startsWith(github.event.commits[0].message, '[CI-Skip]')"
runs-on: ubuntu-20.04
outputs:
upstream: ${{ steps.check-paper.outputs.upstream }}
paper: ${{ steps.check-paper.outputs.paper }}
before: ${{ steps.check-paper.outputs.before }}
steps:
- name: Checkout action
uses: actions/checkout@main
- name: Clone Repository
run: |
git clone --recursive -b ${{ env.prib }} https://github.com/${{ env.pris }}.git
- name: Check Paper commit
id: check-paper
run: |
upstream=$(git ls-remote https://github.com/${{ env.paper }} | grep heads/${{ env.papb }} | cut -f 1)
current=$(cat KPaper/gradle.properties | grep paperRef | sed 's/paperRef=//')
if [ "$current" != "$upstream" ]; then paper=true; else paper=false; fi
echo "::set-output name=paper::$paper"
echo "::set-output name=before::$current"
echo "::set-output name=upstream::$upstream"
echo "Current Paper commit: $current / Latest Paper commit: $upstream"
echo "Need upstream: $paper"
upstream-paper:
name: Upstream Paper
runs-on: ubuntu-20.04
needs: [check]
if: needs.check.outputs.paper == 'true'
steps:
- name: Checkout action
uses: actions/checkout@main
- name: Setup java
uses: actions/setup-java@main
with:
distribution: temurin
java-version: 17.0.3
- name: Configure Git
run: git config --global user.email "norhu1130@naver.com" && git config --global user.name "norhu1130"
- name: Clone Repository
run: git clone --recursive -b ${{ env.prib }} https://github.com/${{ env.pris }}.git
- name: Update Upstream
run: |
cd KPaper
sed -i 's/paperRef=.*/paperRef='"${{ needs.check.outputs.upstream }}"'/' gradle.properties
./gradlew applyPatches --stacktrace
- name: Rebuild Patches
run: |
cd KPaper
./gradlew rebuildPatches
- name: Commit Changes
run: |
cd KPaper
git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
commit=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ env.paper }}/compare/${{ needs.check.outputs.before }}...HEAD | jq -r '.commits[] | "\n${{ env.paper }}@\(.sha[:7]) \(.commit.message | split("\r\n")[0] | split("\n")[0])"')
log="Updated Upstream (Paper)\n\nUpstream has released updates that appear to apply and compile correctly\n\nPaper Changes:\n$commit"
git add .
echo -e "$log" | git commit -F -
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.PUSH_TOKEN }}
directory: ./KPaper
repository: KPaperMC/KPaper