Skip to content

Commit

Permalink
fix: modularization
Browse files Browse the repository at this point in the history
  • Loading branch information
sneazy-ibo committed Jun 19, 2024
1 parent fdec506 commit cb26cbd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ jobs:
retention-days: 5
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:
Expand Down
46 changes: 25 additions & 21 deletions .github/workflows/discord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ jobs:
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]}
Expand All @@ -40,51 +38,57 @@ jobs:
if [[ -n "${author_map[$author_name]}" ]]; then
author_info+=("$author_name|$author_login|${author_map[$author_name]}")
else
authors+=("$author_name")
author_info+=("$author_name|$author_login")
fi
fi
done <<< "$commits"
# Print author information in the desired format
if [ "${#authors[@]}" -gt 0 ]; then
echo "Missing information for the following authors: ${authors[*]}"
echo "Please provide their Discord IDs and AniList usernames in the author_map variable."
return 1
fi
if [ "${#author_info[@]}" -eq 1 ]; then
IFS='|' read -ra author_data <<< "${author_info[0]}"
author_name=${author_data[0]}
author_login=${author_data[1]}
if [ "${#author_info[@]}" -eq 1 ]; then
IFS='|' read -ra author_data <<< "${author_info[0]}"
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]#*|}
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://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]}
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"
done
fi
else
developer_field+="◗ **$author_name**\n- Github: [$author_name](<https://github.com/$author_login>)\n"
fi
done
fi
echo "$thumbnail_url"
echo "$developer_field"
}
echo "$thumbnail_url"
echo "$developer_field"
}
#Discord
commit_messages=$(echo "${{ inputs.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
Expand Down

0 comments on commit cb26cbd

Please sign in to comment.