From 939ea8299399a8879bb015a646e0d09a65f35d8f Mon Sep 17 00:00:00 2001 From: ibo <41344259+sneazy-ibo@users.noreply.github.com> Date: Fri, 21 Jun 2024 03:56:15 +0200 Subject: [PATCH] fix: formatting --- .github/workflows/beta.yml | 56 ++++++++++---------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 858dd1d2..e27c281e 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -96,7 +96,6 @@ jobs: - name: Upload APK to Discord and Telegram shell: bash run: | - set -x # Function to fetch user details fetch_user_details() { local login=$1 @@ -105,42 +104,23 @@ jobs: name=$(echo "$user_details" | jq -r '.name // .login') echo "$name|$login" } - # Extract unique authors from commit log - authors=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g' | grep -oP '~\K[^\n]+' | sort -u) - echo "Extracted authors: $authors" # Fetch contributors contributors=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ "https://api.github.com/repos/rebelonion/Dantotsu/contributors") - echo "Contributors response:" - echo "$contributors" | jq '.' - # Validate contributors JSON - if ! echo "$contributors" | jq empty; then - echo "Error: Invalid JSON in contributors response" - exit 1 - fi # Process contributors developers="" - while read -r author; do - echo "Processing author: $author" - ccontributor=$(echo "$contributors" | jq -r ".[] | select(.login | ascii_downcase == \"$(echo $author | tr '[:upper:]' '[:lower:])\")") - if [ ! -z "$contributor" ]; then - login=$(echo "$contributor" | jq -r '.login') - commits=$(echo "$contributor" | jq -r '.contributions') - user_info=$(fetch_user_details "$login") - name=$(echo "$user_info" | cut -d'|' -f1) - developers="${developers}◗ **${name}** + while read -r login commits; do + user_info=$(fetch_user_details "$login") + name=$(echo "$user_info" | cut -d'|' -f1) + login=$(echo "$user_info" | cut -d'|' -f2) + developers="${developers}◗ **${name}** - Github: [${login}](https://github.com/${login}) - Commits: ${commits} - + " - else - echo "No contributor found for author: $author" - fi - done <<< "$authors" + done < <(echo "$contributors" | jq -r '.[] | "\(.login) \(.contributions)"') # Remove trailing newline - developers=$(echo "$developers" | sed '$ s/\n$//') - echo "Developers string:" - echo "$developers" + developers=$(echo "$developers" | sed '$ s/$//') # Truncate developers if too long max_length=1000 if [ ${#developers} -gt $max_length ]; then @@ -151,8 +131,6 @@ jobs: if [ ${#commit_messages} -gt $max_length ]; then commit_messages="${commit_messages:0:$max_length}... (truncated)" fi - echo "Commit messages:" - echo "$commit_messages" # Construct Discord payload discord_data=$(jq -nc \ --arg field_value "$commit_messages" \ @@ -189,27 +167,21 @@ jobs: ], "attachments": [] }') - echo "Discord payload:" - echo "$discord_data" | jq '.' - # Send Discord message - response=$(curl -H "Content-Type: application/json" \ + curl -H "Content-Type: application/json" \ -d "$discord_data" \ - ${{ secrets.DISCORD_WEBHOOK }}) - echo "Discord response: $response" + ${{ secrets.DISCORD_WEBHOOK }} # Upload APK to Discord - response=$(curl -F "payload_json=${contentbody}" \ + curl -F "payload_json=${contentbody}" \ -F "dantotsu_debug=@app/build/outputs/apk/google/alpha/app-google-alpha.apk" \ - ${{ secrets.DISCORD_WEBHOOK }}) - echo "Discord APK upload response: $response" + ${{ secrets.DISCORD_WEBHOOK }} # Send Telegram message and upload APK - response=$(curl -F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \ + curl -F "chat_id=${{ secrets.TELEGRAM_CHANNEL_ID }}" \ -F "document=@app/build/outputs/apk/google/alpha/app-google-alpha.apk" \ -F "caption=Alpha-Build: ${VERSION}: ${commit_messages}" \ - https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument) - echo "Telegram response: $response" + https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendDocument env: COMMIT_LOG: ${{ env.COMMIT_LOG }}