Changed melon jacob limit to 5m #249
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: Build Gradle project | |
on: | |
push: | |
pull_request: | |
jobs: | |
build-gradle-project: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Set up Java environment using Zulu JDK 17 | |
- uses: actions/[email protected] | |
with: | |
distribution: 'zulu' | |
java-version: '17' | |
# Step 2: Check out the source code of the repository | |
- name: Checkout project sources | |
uses: actions/[email protected] | |
# Step 3: Set up Gradle and build the project | |
- name: Setup Gradle and build | |
uses: gradle/[email protected] | |
with: | |
arguments: build | |
# Step 4: Upload built JAR files as artifacts | |
- name: Upload a Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: artifacts | |
path: build/libs/*.jar | |
# Step 5: Check for required secret variables | |
- name: Check for GH_TOKEN and DISCORD_WEBHOOK_URL | |
id: check_secrets | |
run: | | |
if [[ -z "${{ secrets.GH_TOKEN }}" || -z "${{ secrets.DISCORD_WEBHOOK_URL }}" ]]; then | |
echo "Secrets GH_TOKEN or DISCORD_WEBHOOK_URL not provided, skipping tasks" | |
echo "::set-output name=result::failure" | |
else | |
echo "::set-output name=result::success" | |
fi | |
# Step 6: Fetch details of the latest commit using GitHub API | |
- name: Fetch latest commit details | |
id: latest_commit | |
if: steps.check_secrets.outputs.result == 'success' | |
run: | | |
COMMIT_API_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" "https://api.github.com/repos/JellyLabScripts/FarmHelper/commits?per_page=1") | |
COMMIT_MESSAGE=$(echo "$COMMIT_API_RESPONSE" | jq -r '.[0].commit.message') | |
COMMIT_SHA=$(echo "$COMMIT_API_RESPONSE" | jq -r '.[0].sha') | |
COMMIT_URL=$(echo "$COMMIT_API_RESPONSE" | jq -r '.[0].html_url') | |
SHORT_COMMIT_SHA=$(echo "$COMMIT_SHA" | cut -c 1-7) | |
echo "::set-output name=commit_message::$COMMIT_MESSAGE" | |
echo "::set-output name=commit_url::$COMMIT_URL" | |
echo "::set-output name=short_commit_sha::$SHORT_COMMIT_SHA" | |
# Step 7: Send an embed message with commit details to Discord | |
- name: Send embed message with timestamp and footer | |
if: steps.check_secrets.outputs.result == 'success' | |
run: | | |
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%S.%3NZ) | |
LONG_DATE=$(date -u +"%A, %B %-d, %Y at %T") | |
COMMIT_MESSAGE="${{ steps.latest_commit.outputs.commit_message }}" | |
COMMIT_URL="${{ steps.latest_commit.outputs.commit_url }}" | |
SHORT_COMMIT_SHA="${{ steps.latest_commit.outputs.short_commit_sha }}" | |
curl -X POST -H "Content-Type: application/json" \ | |
-d "{ | |
\"embeds\": [ | |
{ | |
\"title\": \"FarmHelper Update\", | |
\"description\": \"FarmHelper has been updated with the following changes:\", | |
\"color\": 3447003, | |
\"thumbnail\": { | |
\"url\": \"https://cdn.discordapp.com/attachments/861700235890130986/1144673641951395982/icon.png\" | |
}, | |
\"fields\": [ | |
{ | |
\"name\": \"Latest Commit\", | |
\"value\": \"**${COMMIT_MESSAGE}**\" | |
}, | |
{ | |
\"name\": \"Commit ID\", | |
\"value\": \"[View Commit (${SHORT_COMMIT_SHA})](${COMMIT_URL})\\n_To learn more about the changes, click on the link!_\" | |
} | |
], | |
\"footer\": { | |
\"text\": \"Updated: ${LONG_DATE}\" | |
} | |
} | |
] | |
}" \ | |
${{ secrets.DISCORD_WEBHOOK_URL }} | |
# Step 8: Send built JAR files to Discord webhook | |
- name: Send build artifacts to Discord webhook | |
if: steps.check_secrets.outputs.result == 'success' | |
run: | | |
cd build/libs | |
for file in *.jar; do | |
curl -X POST -H "Content-Type: multipart/form-data" \ | |
-F "file=@$file" \ | |
${{ secrets.DISCORD_WEBHOOK_URL }} | |
done |