From c4dbaaf32a53fccf912afce8f1d1fb383bf3f41c Mon Sep 17 00:00:00 2001
From: ibo <41344259+sneazy-ibo@users.noreply.github.com>
Date: Mon, 24 Jun 2024 22:59:06 +0200
Subject: [PATCH] feat: dynamic embed colors
---
.github/workflows/beta.yml | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml
index 8a20867d..9a7396bf 100644
--- a/.github/workflows/beta.yml
+++ b/.github/workflows/beta.yml
@@ -120,11 +120,20 @@ jobs:
avatar_url=$(echo "$user_details" | jq -r '.avatar_url')
echo "$name|$login|$avatar_url"
}
+
# Additional information for the goats
declare -A additional_info
additional_info["ibo"]="\n Discord: <@951737931159187457>\n AniList: [takarealist112]()"
additional_info["aayush262"]="\n Discord: <@918825160654598224>\n AniList: [aayush262]()"
- additional_info["rebelonion"]="\n Discord: <@714249925248024617>\n AniList: [rebelonion]()\n PornHub: [rebelonion]()"
+ additional_info["rebelonion"]="\n Discord: <@714249925248024617>\n AniList: [rebelonion]()\n PornHub: [rebelonion]()"
+
+ # Decimal color codes for contributors
+ declare -A contributor_colors
+ contributor_colors["ibo"]=16741632 # Hex: #ff7500
+ contributor_colors["aayush262"]=6121629 # Hex: #5d689d
+ contributor_colors["Sadwhy"]=16744085 # Hex: #ff7e95
+ contributor_colors["rebelonion"]=13952493 # Hex: #d4e5ed
+ default_color=16721401 # Hex: #ff25f9
# Count recent commits and create an associative array
declare -A recent_commit_counts
@@ -150,6 +159,7 @@ jobs:
top_contributor=""
top_contributor_count=0
top_contributor_avatar=""
+ embed_color=$default_color
# Process contributors in the new order
while read -r login; do
@@ -164,11 +174,14 @@ jobs:
# Update top contributor information
if [ $commit_count -gt $max_commits ]; then
max_commits=$commit_count
- top_contributor="$login"
+ top_contributors=("$login")
top_contributor_count=1
top_contributor_avatar="$avatar_url"
+ embed_color=${contributor_colors[$login]:-$default_color}
elif [ $commit_count -eq $max_commits ]; then
+ top_contributors+=("$login")
top_contributor_count=$((top_contributor_count + 1))
+ embed_color=$default_color
fi
# Get commit count for this contributor on the dev branch
@@ -191,16 +204,16 @@ jobs:
else
developers="${developer_entry}"
fi
-
committers_count=$((committers_count + 1))
fi
done <<< "$sorted_contributors"
- # Set the thumbnail URL based on top contributor(s)
+ # Set the thumbnail URL and color based on top contributor(s)
if [ $top_contributor_count -eq 1 ]; then
thumbnail_url="$top_contributor_avatar"
else
thumbnail_url="https://i.imgur.com/5o3Y9Jb.gif"
+ embed_color=$default_color
fi
# Truncate field values
@@ -220,12 +233,13 @@ jobs:
--arg footer_text "Version $VERSION" \
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \
--arg thumbnail_url "$thumbnail_url" \
+ --argjson embed_color "$embed_color" \
'{
"content": "<@&1225347048321191996>",
"embeds": [
{
"title": "New Alpha-Build dropped",
- "color": 15532323,
+ "color": $embed_color,
"fields": [
{
"name": "Commits:",