11name : Mod Build
22on :
33 - pull_request
4- - push
4+ - push
55 - workflow_dispatch
6+
67jobs :
78 build :
89 runs-on : blacksmith-4vcpu-ubuntu-2404
@@ -11,33 +12,63 @@ jobs:
1112 uses : actions/checkout@v4
1213 with :
1314 fetch-depth : 200
15+
1416 - name : Set up JDK 17
1517 uses : useblacksmith/setup-java@v5
1618 with :
1719 java-version : 17
1820 distribution : zulu
1921 cache : gradle
22+
2023 - name : Loom Cache
2124 uses : useblacksmith/cache@v5
2225 with :
2326 path : " **/.gradle/loom-cache"
2427 key : " ${{ runner.os }}-gradle-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}"
2528 restore-keys : " ${{ runner.os }}-gradle-"
29+
2630 - uses : gradle/actions/wrapper-validation@v4
31+
2732 - run : chmod +x ./gradlew
33+
2834 - name : Run datagen and build
2935 run : ./gradlew :fabric:runDatagen build
3036 env :
3137 MAVEN_PASSWORD : ${{ secrets.MAVEN_PASSWORD }}
38+
3239 - name : Upload Build Artifacts forge
3340 uses : actions/upload-artifact@v4
3441 with :
3542 name : IamMusicPlayerRenewedForge
3643 path : forge/build/libs
3744 compression-level : 9
45+
3846 - name : Upload Build Artifacts fabric
3947 uses : actions/upload-artifact@v4
4048 with :
4149 name : IamMusicPlayerRenewedFabric
4250 path : fabric/build/libs
4351 compression-level : 9
52+
53+ - name : Install GitHub CLI
54+ if : failure()
55+ run : sudo apt update && sudo apt install -y gh
56+
57+ - name : Dump logs and notify Discord
58+ if : failure()
59+ env :
60+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
61+ DISCORD_WEBHOOK_URL : ${{ secrets.IAMLOGGER }}
62+ run : |
63+ mkdir logs
64+ gh run download $GITHUB_RUN_ID -D logs
65+
66+ # Extract the last 100 lines from all logs (or change as needed)
67+ output=$(find logs -type f -name '*.txt' -exec tail -n 100 {} \; | sed 's/"/\\"/g' | head -c 1800)
68+
69+ payload="{\"content\": \"❌ **Build failed!**\n\`\`\`\n$output\n\`\`\`\"}"
70+
71+ curl -H "Content-Type: application/json" \
72+ -X POST \
73+ -d "$payload" \
74+ "$DISCORD_WEBHOOK_URL"
0 commit comments