Automatically update Gale commit hash #306
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automatically update Gale commit hash | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 1 * * *" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Leaf repository | |
uses: actions/checkout@main | |
with: | |
path: 'Leaf' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout Gale repository | |
uses: actions/checkout@main | |
with: | |
path: 'Gale' | |
repository: "Dreeam-qwq/Gale" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Get Gale latest commit Hash | |
id: galeCommit | |
run: | | |
cd Gale | |
echo "galeCommit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Get Leaf Current Gale commit Hash | |
id: currGaleRef | |
run: | | |
cd Leaf | |
currGaleRef=$(grep "^galeCommit\s*=" gradle.properties | sed 's/^galeCommit\s*=\s*//') | |
echo "currGaleRef=$currGaleRef" >> $GITHUB_OUTPUT | |
- name: Update galeCommit in Leaf | |
run: | | |
cd Leaf | |
sed -i "s/\(galeCommit\s*=\s*\).*/\1$PAPER_REF/" gradle.properties | |
env: | |
PAPER_REF: ${{ steps.galeCommit.outputs.galeCommit }} | |
- name: Grant execute permission for gradlew | |
run: | | |
cd Leaf | |
git config --global user.name "Dreeam" | |
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 applyPatches | |
./gradlew createMojmapPaperclipJar | |
./gradlew rebuildPatches | |
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 --gale $CURR_GALE_REF | |
git push | |
else | |
echo "No changes to commit." | |
fi | |
env: | |
CURR_GALE_REF: ${{ steps.currGaleRef.outputs.currGaleRef }} |