Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

Automatically update Leaf commit hash #20

Automatically update Leaf commit hash

Automatically update Leaf commit hash #20

Workflow file for this run

name: Automatically update Leaf commit hash
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Sapling repository
uses: actions/checkout@v4
with:
path: 'Sapling'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Leaf repository
uses: actions/checkout@v4
with:
path: 'Leaf'
repository: "Winds-Studio/Leaf"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get Leaf latest commit Hash
id: leafCommit
run: |
cd Leaf
echo "leafCommit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Get Sapling Current Leaf commit Hash
id: currLeafCommit
run: |
cd Sapling
currLeafCommit=$(grep "^leafCommit\s*=" gradle.properties | sed 's/^leafCommit\s*=\s*//')
echo "currLeafCommit=$currLeafCommit" >> $GITHUB_OUTPUT
- name: Update leafCommit in Sapling
run: |
cd Sapling
sed -i "s/\(leafCommit\s*=\s*\).*/\1$LEAF_COMMIT/" gradle.properties
env:
LEAF_COMMIT: ${{ steps.leafCommit.outputs.leafCommit }}
- name: Grant execute permission for gradlew
run: |
cd Sapling
git config --global user.name "Dreeam-qwq"
git config --global user.email 61569423+Dreeam-qwq@users.noreply.github.com
chmod +x gradlew
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
- name: Running tests before push
run: |
cd Sapling
if ! git diff --quiet; then
echo "Running tests...."
./gradlew applyAllPatches
./gradlew build -x test -x javadoc
./gradlew rebuildLeafPatches
./gradlew rebuildAllServerPatches
fi
- name: Check for changes and write to repository
run: |
cd Sapling
if ! git diff --quiet; then
echo "Writing to repo....."
git add .
git commit -m "Updated Upstream (Leaf)"
git push
else
echo "No changes to commit."
fi
env:
CURR_LEAF_COMMIT: ${{ steps.currLeafCommit.outputs.currLeafCommit }}