From a2ca6641219725c2dc4d5a65ea58d38137616381 Mon Sep 17 00:00:00 2001 From: Loi Phan <123229563+Nez27@users.noreply.github.com> Date: Tue, 21 Jan 2025 00:14:45 +0700 Subject: [PATCH] Update build.yml --- .github/workflows/build.yml | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afd7050..f0c8b2f 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,3 +145,42 @@ jobs: MSG=${MSG:0:9450} POST="https://api.telegram.org/bot${TG_TOKEN}/sendMessage" curl -X POST --data-urlencode "parse_mode=Markdown" --data-urlencode "disable_web_page_preview=true" --data-urlencode "text=${MSG}" --data-urlencode "chat_id=${TG_CHAT}" "$POST" + + - name: Report to Discord + if: env.TG_TOKEN != null + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + run: | + cd build || { echo "build folder not found"; exit 1; } + + NL=$'\n' + APKS="" + MODULES="" + for OUTPUT in *; do + DL_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/${{ steps.next_ver_code.outputs.NEXT_VER_CODE }}/${OUTPUT}" + if [[ $OUTPUT = *.apk ]]; then + APKS+="${NL}- [${OUTPUT}](${DL_URL})" + elif [[ $OUTPUT = *.zip ]]; then + MODULES+="${NL}- [${OUTPUT}](${DL_URL})" + fi + done + + MODULES=${MODULES#"$NL"} + APKS=${APKS#"$NL"} + + BODY="$(sed 's/^\* \*\*/- \*\*/g; s/^\* `/- \*\*/g; s/`/\*/g; s/^\* /\-/g; s/\*\*/\*/g; s/###//g; s/^- /- /g; /^==/d;' ../build.md)" + MSG="**New build is ready!** + + ${BODY} + + **Download Links:** + **Modules:** + ${MODULES} + + **APKs:** + ${APKS} + " + + curl -X POST -H "Content-Type: application/json" \ + -d "$(jq -n --arg content "$MSG" '{content: $content}')" \ + "$DISCORD_WEBHOOK_URL"