Skip to content

Automatically update Paper commit hash #648

Automatically update Paper commit hash

Automatically update Paper commit hash #648

Workflow file for this run

name: Automatically update Paper commit hash
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Leaf repository
uses: actions/checkout@v4
with:
path: 'Leaf'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Paper repository
uses: actions/checkout@v4
with:
path: 'Paper'
repository: "PaperMC/Paper"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get Paper latest commit Hash
id: paperCommit
run: |
cd Paper
echo "paperCommit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Get Leaf Current Paper commit Hash
id: currPaperCommit
run: |
cd Leaf
currPaperCommit=$(grep "^paperCommit\s*=" gradle.properties | sed 's/^paperCommit\s*=\s*//')
echo "currPaperCommit=$currPaperCommit" >> $GITHUB_OUTPUT
- name: Update paperCommit in Leaf
run: |
cd Leaf
sed -i "s/\(paperCommit\s*=\s*\).*/\1$PAPER_COMMIT/" gradle.properties
env:
PAPER_COMMIT: ${{ steps.paperCommit.outputs.paperCommit }}
- name: Grant execute permission for gradlew
run: |
cd Leaf
git config --global user.name "Dreeam-qwq"
git config --global user.email [email protected]
chmod +x gradlew
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
- name: Running tests before push
run: |
cd Leaf
if ! git diff --quiet; then
echo "Running tests...."
./gradlew applyAllPatches
./gradlew build -x test
./gradlew rebuildPaperPatches
./gradlew rebuildAllServerPatches
fi
- name: Check for changes and write to repository
run: |
cd Leaf
if ! git diff --quiet; then
echo "Writing to repo....."
git add .
chmod +x ./scripts/upstreamCommit.sh
./scripts/upstreamCommit.sh --paper $CURR_PAPER_COMMIT
git push
else
echo "No changes to commit."
fi
env:
CURR_PAPER_COMMIT: ${{ steps.currPaperCommit.outputs.currPaperCommit }}