Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75c3378

Browse files
committed
feat: add manual workflow_dispatch trigger with [TEST] mode for Discord notifications
1 parent 387a5ea commit 75c3378

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ on:
44
push:
55
branches:
66
- main
7+
workflow_dispatch:
8+
inputs:
9+
test_discord:
10+
description: 'Test Discord notification (will be marked as [TEST])'
11+
required: false
12+
type: boolean
13+
default: false
714

815
concurrency: ${{ github.workflow }}-${{ github.ref }}
916

@@ -55,28 +62,39 @@ jobs:
5562
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5663
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5764

58-
- if: steps.changesets.outputs.published == 'true'
65+
- if: steps.changesets.outputs.published == 'true' || inputs.test_discord == true
5966
name: Notify Discord about new release
6067
env:
6168
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
6269
PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }}
70+
IS_TEST: ${{ inputs.test_discord == true }}
6371
run: |
64-
# Parse the published packages and create a Discord message
65-
PACKAGES=$(echo "$PUBLISHED_PACKAGES" | jq -r '.[] | "• \(.name)@\(.version)"' 2>/dev/null || echo "• New packages published")
72+
# Determine if this is a test run
73+
if [ "$IS_TEST" = "true" ]; then
74+
TEST_PREFIX="[TEST] "
75+
TITLE="${TEST_PREFIX}Test Discord Notification"
76+
PACKAGES="• This is a test notification to verify Discord webhook integration"
77+
else
78+
TEST_PREFIX=""
79+
TITLE="New packages have been published to npm"
80+
# Parse the published packages and create a Discord message
81+
PACKAGES=$(echo "$PUBLISHED_PACKAGES" | jq -r '.[] | "• \(.name)@\(.version)"' 2>/dev/null || echo "• New packages published")
82+
fi
6683
6784
# Create the Discord webhook payload
6885
PAYLOAD=$(jq -n \
69-
--arg content "🚀 **New Release Published!**" \
86+
--arg title "$TITLE" \
7087
--arg description "$PACKAGES" \
88+
--arg test_prefix "$TEST_PREFIX" \
7189
'{
7290
"username": "CRXJS Release Bot",
7391
"avatar_url": "https://crxjs.dev/logo.svg",
7492
"embeds": [{
75-
"title": "New packages have been published to npm",
93+
"title": $title,
7694
"description": $description,
7795
"color": 2105893,
7896
"footer": {
79-
"text": "CRXJS Chrome Extension Tools"
97+
"text": ($test_prefix + "CRXJS Chrome Extension Tools")
8098
},
8199
"timestamp": (now | strftime("%Y-%m-%dT%H:%M:%SZ"))
82100
}]

0 commit comments

Comments
 (0)