Skip to content

Commit

Permalink
back to balling
Browse files Browse the repository at this point in the history
  • Loading branch information
sneazy-ibo authored Jun 19, 2024
1 parent cb26cbd commit e39fbfa
Showing 1 changed file with 128 additions and 7 deletions.
135 changes: 128 additions & 7 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,135 @@ jobs:
compression-level: 9
path: "app/build/outputs/apk/google/alpha/app-google-alpha.apk"

- name: Checkout repo
uses: actions/checkout@v4

- name: Upload APK to Discord
uses: ./.github/workflows/discord.yml
with:
commit_log: ${{ env.COMMIT_LOG }}
version: ${{ env.VERSION }}
shell: bash
run: |
declare -A author_map=(
["ibo"]="951737931159187457|takarealist112"
["aayush262"]="918825160654598224|aayush262"
)
function get_author_info() {
local commits=$1
local authors=()
local author_info=()
# Extract author names, logins, and gather user-provided information
while read -r line; do
if [[ $line =~ ^●\ .* ~(.*)$ ]]; then
author=${BASH_REMATCH[1]}
author_name=$(echo "$author" | cut -d'<' -f1 | xargs)
author_login=$(echo "$author" | cut -d'<' -f2 | cut -d'>' -f1 | xargs)
# Add author name and login to the list if not already present
if ! printf '%s\n' "${authors[@]}" | grep -q "$author_name"; then
authors+=("$author_name|$author_login")
if [[ -n "${author_map[$author_name]}" ]]; then
author_info+=("$author_name|$author_login|${author_map[$author_name]}")
else
author_info+=("$author_name|$author_login")
fi
fi
fi
done <<< "$commits"
# Print author information in the desired format
if [ "${#authors[@]}" -eq 1 ]; then
IFS='|' read -ra author_data <<< "${authors[0]}"
author_name=${author_data[0]}
author_login=${author_data[1]}
if [[ -n "${author_map[$author_name]}" ]]; then
IFS='|' read -ra author_info <<< "${author_info[0]}"
discord_id=${author_info[2]%|*}
anilist_username=${author_info[2]#*|}
thumbnail_url="https://avatars.githubusercontent.com/u/$author_login"
developer_field="◗ **$author_name**\n- Discord: <@$discord_id>\n- Github: [$author_name](<https://github.com/$author_login>)\n- Anilist: [$anilist_username](<https://anilist.co/user/$anilist_username>)"
else
thumbnail_url="https://avatars.githubusercontent.com/u/$author_login"
developer_field="◗ **$author_name**\n- Github: [$author_name](<https://github.com/$author_login>)"
fi
else
thumbnail_url="https://i.imgur.com/5o3Y9Jb.gif"
developer_field=""
for author_data in "${author_info[@]}"; do
IFS='|' read -ra author_data <<< "$author_data"
author_name=${author_data[0]}
author_login=${author_data[1]}
if [ "${#author_data[@]}" -eq 3 ]; then
discord_id=${author_data[2]%|*}
anilist_username=${author_data[2]#*|}
developer_field+="◗ **$author_name**\n- Discord: <@$discord_id>\n- Github: [$author_name](<https://github.com/$author_login>)\n- Anilist: [$anilist_username](<https://anilist.co/user/$anilist_username>)\n"
else
developer_field+="◗ **$author_name**\n- Github: [$author_name](<https://github.com/$author_login>)\n"
fi
done
fi
echo "$thumbnail_url"
echo "$developer_field"
}
#Discord
commit_messages=$(echo "$COMMIT_LOG" | sed 's/%0A/\n/g; s/^/\n/')
max_length=1000
if [ ${#commit_messages} -gt $max_length ]; then
commit_messages="${commit_messages:0:$max_length}... (truncated)"
fi
# Get author information
read -r thumbnail_url developer_field < <(get_author_info "$commit_messages")
if [ $? -ne 0 ]; then
exit 1
fi
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 "$thumbnail_url" \
--arg developer_field "$developer_field" \
'{
"content": null,
"embeds": [
{
"title": "New Alpha-Build dropped",
"description": "<@&1225347048321191996>",
"color": 15532323,
"fields": [
{
"name": "Commits:",
"value": $field_value,
"inline": true
},
{
"name": "Developers:",
"value": $developer_field,
"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 "dantotsu_debug=@app/build/outputs/apk/google/alpha/app-google-alpha.apk" \
${{ secrets.DISCORD_WEBHOOK }}
env:
COMMIT_LOG: ${{ env.COMMIT_LOG }}
VERSION: ${{ env.VERSION }}

- name: Upload Current SHA as Artifact
uses: actions/upload-artifact@v4
Expand Down

0 comments on commit e39fbfa

Please sign in to comment.