|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - 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 |
7 | 14 |
|
8 | 15 | concurrency: ${{ github.workflow }}-${{ github.ref }} |
9 | 16 |
|
@@ -55,28 +62,39 @@ jobs: |
55 | 62 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
56 | 63 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
57 | 64 |
|
58 | | - - if: steps.changesets.outputs.published == 'true' |
| 65 | + - if: steps.changesets.outputs.published == 'true' || inputs.test_discord == true |
59 | 66 | name: Notify Discord about new release |
60 | 67 | env: |
61 | 68 | DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} |
62 | 69 | PUBLISHED_PACKAGES: ${{ steps.changesets.outputs.publishedPackages }} |
| 70 | + IS_TEST: ${{ inputs.test_discord == true }} |
63 | 71 | 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 |
66 | 83 | |
67 | 84 | # Create the Discord webhook payload |
68 | 85 | PAYLOAD=$(jq -n \ |
69 | | - --arg content "🚀 **New Release Published!**" \ |
| 86 | + --arg title "$TITLE" \ |
70 | 87 | --arg description "$PACKAGES" \ |
| 88 | + --arg test_prefix "$TEST_PREFIX" \ |
71 | 89 | '{ |
72 | 90 | "username": "CRXJS Release Bot", |
73 | 91 | "avatar_url": "https://crxjs.dev/logo.svg", |
74 | 92 | "embeds": [{ |
75 | | - "title": "New packages have been published to npm", |
| 93 | + "title": $title, |
76 | 94 | "description": $description, |
77 | 95 | "color": 2105893, |
78 | 96 | "footer": { |
79 | | - "text": "CRXJS Chrome Extension Tools" |
| 97 | + "text": ($test_prefix + "CRXJS Chrome Extension Tools") |
80 | 98 | }, |
81 | 99 | "timestamp": (now | strftime("%Y-%m-%dT%H:%M:%SZ")) |
82 | 100 | }] |
|
0 commit comments