Skip to content

feature: add light mode toggle and global theme support #459

feature: add light mode toggle and global theme support

feature: add light mode toggle and global theme support #459

Workflow file for this run

name: Discord Notifications
on:
pull_request:
types: [opened, closed, reopened, synchronize]
issues:
types: [opened, closed, reopened]
issue_comment:
types: [created, edited, deleted]
release:
types: [published, created, edited, deleted]
push:
branches:
- main
- develop
watch:
types: [started]
jobs:
notify:
runs-on: ubuntu-latest
if: github.event.repository != null
steps:
- name: Extract event data
id: extract
run: |
EVENT_TYPE="${{ github.event_name }}"
REPO_NAME="${{ github.repository }}"
REPO_URL="${{ github.server_url }}/${{ github.repository }}"
case "$EVENT_TYPE" in
pull_request)
TITLE="${{ github.event.pull_request.title }}"
AUTHOR="${{ github.event.pull_request.user.login }}"
AUTHOR_URL="${{ github.event.pull_request.user.html_url }}"
AUTHOR_AVATAR="${{ github.event.pull_request.user.avatar_url }}"
EVENT_URL="${{ github.event.pull_request.html_url }}"
ACTION="${{ github.event.action }}"
DESCRIPTION="Pull Request $ACTION: $TITLE"
COLOR="3447003"
;;
issues)
TITLE="${{ github.event.issue.title }}"
AUTHOR="${{ github.event.issue.user.login }}"
AUTHOR_URL="${{ github.event.issue.user.html_url }}"
AUTHOR_AVATAR="${{ github.event.issue.user.avatar_url }}"
EVENT_URL="${{ github.event.issue.html_url }}"
ACTION="${{ github.event.action }}"
DESCRIPTION="Issue $ACTION: $TITLE"
COLOR="11027200"
;;
issue_comment)
TITLE="${{ github.event.issue.title }}"
AUTHOR="${{ github.event.comment.user.login }}"
AUTHOR_URL="${{ github.event.comment.user.html_url }}"
AUTHOR_AVATAR="${{ github.event.comment.user.avatar_url }}"
EVENT_URL="${{ github.event.comment.html_url }}"
ACTION="${{ github.event.action }}"
COMMENT_BODY="${{ github.event.comment.body }}"
COMMENT_BODY="${COMMENT_BODY:0:100}..."
DESCRIPTION="Comment $ACTION on: $TITLE"
COLOR="10181046"
;;
release)
TITLE="${{ github.event.release.name }}"
AUTHOR="${{ github.event.release.author.login }}"
AUTHOR_URL="${{ github.event.release.author.html_url }}"
AUTHOR_AVATAR="${{ github.event.release.author.avatar_url }}"
EVENT_URL="${{ github.event.release.html_url }}"
ACTION="${{ github.event.action }}"
DESCRIPTION="Release $ACTION: $TITLE"
COLOR="6632143"
;;
push)
TITLE="${{ github.event.ref }}"
AUTHOR="${{ github.event.pusher.name }}"
AUTHOR_URL="${{ github.server_url }}/${{ github.event.pusher.name }}"
AUTHOR_AVATAR="https://github.com/${{ github.event.pusher.name }}.png"
EVENT_URL="$REPO_URL/commit/${{ github.sha }}"
COMMITS_COUNT="${{ github.event.commits }}"
COMMITS_COUNT=${#COMMITS_COUNT[@]}
DESCRIPTION="Push to $TITLE ($COMMITS_COUNT commits)"
COLOR="2105893"
;;
watch)
TITLE="Repository Starred"
AUTHOR="${{ github.event.sender.login }}"
AUTHOR_URL="${{ github.event.sender.html_url }}"
AUTHOR_AVATAR="${{ github.event.sender.avatar_url }}"
EVENT_URL="$REPO_URL"
DESCRIPTION="$AUTHOR starred the repository"
COLOR="16776960"
;;
*)
TITLE="Unknown Event"
AUTHOR="Unknown"
AUTHOR_URL="$REPO_URL"
AUTHOR_AVATAR="https://github.com/fluidicon.png"
EVENT_URL="$REPO_URL"
DESCRIPTION="Event type: $EVENT_TYPE"
COLOR="9807270"
;;
esac
echo "event_type=$EVENT_TYPE" >> $GITHUB_OUTPUT
echo "repo_name=$REPO_NAME" >> $GITHUB_OUTPUT
echo "repo_url=$REPO_URL" >> $GITHUB_OUTPUT
echo "title=$TITLE" >> $GITHUB_OUTPUT
echo "author=$AUTHOR" >> $GITHUB_OUTPUT
echo "author_url=$AUTHOR_URL" >> $GITHUB_OUTPUT
echo "author_avatar=$AUTHOR_AVATAR" >> $GITHUB_OUTPUT
echo "event_url=$EVENT_URL" >> $GITHUB_OUTPUT
echo "description=$DESCRIPTION" >> $GITHUB_OUTPUT
echo "color=$COLOR" >> $GITHUB_OUTPUT
- name: Send Discord notification
continue-on-error: true
run: |
PAYLOAD=$(cat <<EOF
{
"username": "BetterBugs GitHub Bot",
"avatar_url": "https://github.com/fluidicon.png",
"embeds": [
{
"author": {
"name": "${{ steps.extract.outputs.author }}",
"url": "${{ steps.extract.outputs.author_url }}",
"icon_url": "${{ steps.extract.outputs.author_avatar }}"
},
"title": "${{ steps.extract.outputs.title }}",
"description": "${{ steps.extract.outputs.description }}",
"url": "${{ steps.extract.outputs.event_url }}",
"color": ${{ steps.extract.outputs.color }},
"thumbnail": {
"url": "${{ steps.extract.outputs.author_avatar }}"
},
"fields": [
{
"name": "Repository",
"value": "[${{ steps.extract.outputs.repo_name }}](${{ steps.extract.outputs.repo_url }})",
"inline": true
},
{
"name": "Event Type",
"value": "${{ steps.extract.outputs.event_type }}",
"inline": true
},
{
"name": "User Profile",
"value": "[@${{ steps.extract.outputs.author }}](${{ steps.extract.outputs.author_url }})",
"inline": true
}
],
"timestamp": "$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
}
]
}
EOF
)
curl -X POST \
-H 'Content-type: application/json' \
--data "$PAYLOAD" \
${{ secrets.DISCORD_WEBHOOK }}
- name: Log notification status
if: always()
run: |
echo "✅ Discord notification workflow completed for ${{ steps.extract.outputs.event_type }} event"
echo "💡 If webhook is not configured, the notification step fails silently (continue-on-error: true)"