mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-26 18:29:18 +00:00
83 lines
2.3 KiB
YAML
83 lines
2.3 KiB
YAML
name: Automatically Upstream Purpur
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: "0 0 */3 * *"
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout DivineMC repository
|
|
uses: actions/checkout@main
|
|
with:
|
|
path: 'DivineMC'
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Checkout Purpur repository
|
|
uses: actions/checkout@main
|
|
with:
|
|
path: 'Purpur'
|
|
repository: "PurpurMC/Purpur"
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Get Purpur latest commit Hash
|
|
id: purpurCommit
|
|
run: |
|
|
cd Purpur
|
|
echo "purpurRef=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Get Current Purpur commit Hash
|
|
id: currPurpurRef
|
|
run: |
|
|
cd DivineMC
|
|
currPurpurRef=$(grep "^purpurRef\s*=" gradle.properties | sed 's/^purpurRef\s*=\s*//')
|
|
echo "currPurpurRef=$currPurpurRef" >> $GITHUB_OUTPUT
|
|
|
|
- name: Update purpurRef in DivineMC
|
|
run: |
|
|
cd DivineMC
|
|
sed -i "s/\(purpurRef\s*=\s*\).*/\1$PURPUR_REF/" gradle.properties
|
|
env:
|
|
PURPUR_REF: ${{ steps.purpurCommit.outputs.purpurRef }}
|
|
|
|
- name: Setup Git and Gradle
|
|
run: |
|
|
cd DivineMC
|
|
git config --global user.email "action@github.com"
|
|
git config --global user.name "Github Action"
|
|
chmod +x gradlew
|
|
|
|
- name: Setup JDK 21
|
|
uses: actions/setup-java@main
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '21'
|
|
|
|
- name: Running tests before push
|
|
run: |
|
|
cd DivineMC
|
|
if ! git diff --quiet; then
|
|
echo "Running tests...."
|
|
./gradlew applyAllPatches
|
|
./gradlew build -x test
|
|
./gradlew rebuildPurpurPatches
|
|
./gradlew rebuildAllServerPatches
|
|
fi
|
|
|
|
- name: Check for changes and write to repository
|
|
run: |
|
|
cd DivineMC
|
|
if ! git diff --quiet; then
|
|
echo "Writing to repo....."
|
|
git add .
|
|
chmod +x ./scripts/upstreamCommit.sh
|
|
./scripts/upstreamCommit.sh $CURR_PURPUR_REF
|
|
git push
|
|
else
|
|
echo "No changes to commit."
|
|
fi
|
|
env:
|
|
CURR_PURPUR_REF: ${{ steps.currPurpurRef.outputs.currPurpurRef }}
|