From 7e6fc7e086792219c50a66e60445b44b30a897ba Mon Sep 17 00:00:00 2001 From: ibo <41344259+sneazy-ibo@users.noreply.github.com> Date: Thu, 20 Jun 2024 21:32:21 +0200 Subject: [PATCH] feat: added embeds back --- .github/workflows/beta.yml | 40 +++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 3a62be41..9dddd274 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -40,6 +40,8 @@ jobs: echo "Commits since $LAST_SHA:" # Accumulate commit logs in a shell variable COMMIT_LOGS=$(git log $LAST_SHA..HEAD --pretty=format:"● %s ~%an") + # Replace commit messages with pull request links + COMMIT_LOGS=$(echo "$COMMIT_LOGS" | sed -E 's/#([0-9]+)/[#\1](https:\/\/github.com\/rebelonion\/Dantotsu\/pull\/\1)/g') # URL-encode the newline characters for GitHub Actions COMMIT_LOGS="${COMMIT_LOGS//'%'/'%25'}" COMMIT_LOGS="${COMMIT_LOGS//$'\n'/'%0A'}" @@ -94,12 +96,44 @@ jobs: run: | #Discord commit_messages=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g; s/^/\n/') - # Truncate commit messages if they are too long - max_length=1900 # Adjust this value as needed + max_length=1000 if [ ${#commit_messages} -gt $max_length ]; then commit_messages="${commit_messages:0:$max_length}... (truncated)" fi - contentbody=$( jq -nc --arg msg "Alpha-Build: <@&1225347048321191996> **$VERSION**:" --arg commits "$commit_messages" '{"content": ($msg + "\n" + $commits)}' ) + discord_data=$(jq -nc \ + --arg field_value "$commit_messages" \ + --arg footer_text "Version $VERSION" \ + --arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \ + --arg thumbnail_url "https://avatars.githubusercontent.com/u/41344259?v=4" \ + '{ + "content": "@here", + "embeds": [ + { + "title": "New Alpha-Build dropped", + "color": 15532323, + "fields": [ + { + "name": "Commits:", + "value": $field_value, + "inline": true + } + ], + "footer": { + "text": $footer_text + }, + "timestamp": $timestamp, + "thumbnail": { + "url": $thumbnail_url + } + } + ], + "attachments": [] + }') + echo "$discord_data" + curl -H "Content-Type: application/json" \ + -d "$discord_data" \ + ${{ secrets.DISCORD_WEBHOOK }} + echo "$response_headers" curl -F "payload_json=${contentbody}" -F "dantotsu_debug=@app/build/outputs/apk/google/alpha/app-google-alpha.apk" ${{ secrets.DISCORD_WEBHOOK }} #Telegram