@@ -44,44 +44,43 @@ jobs:
4444 message :
4545 runs-on : ubuntu-latest
4646 steps :
47- - name : New Discussion
48- uses : tsickert/discord-webhook@b217a69502f52803de774ded2b1ab7c282e99645 # v7.0.0
49- if : ${{ (inputs.event_name == 'discussion') }}
50- with :
51- webhook-url : ${{ secrets.env_discord }}
52- avatar-url : https://avatars.githubusercontent.com/u/9919?s=200&v=4
53- embed-author-name : ${{ inputs.event_sender_login }}
54- embed-author-url : ${{ inputs.event_sender_html_url }}
55- embed-author-icon-url : ${{ inputs.event_sender_avatar_url }}
56- embed-title : ${{ inputs.event_discussion_title }}
57- embed-url : ${{ inputs.event_discussion_html_url }}
58- embed-description : A **discussion** has been created in ${{ inputs.repository_name }}.
59- embed-color : 16305330
47+ - name : Send Notification
48+ run : |
49+ if [ "${{ inputs.event_name }}" = "discussion" ]; then
50+ title="${{ inputs.event_discussion_title }}"
51+ url="${{ inputs.event_discussion_html_url }}"
52+ description="A **discussion** has been created in ${{ inputs.repository_name }}."
53+ color=16305330
54+ elif [ "${{ inputs.event_name }}" = "issues" ]; then
55+ title="${{ inputs.event_issue_title }}"
56+ url="${{ inputs.event_issue_html_url }}"
57+ description="An **issue** has been opened in ${{ inputs.repository_name }}."
58+ color=14023876
59+ elif [ "${{ inputs.event_name }}" = "pull_request_target" ]; then
60+ title="${{ inputs.event_pull_request_title }}"
61+ url="${{ inputs.event_pull_request_html_url }}"
62+ description="A **pull request** has been opened in ${{ inputs.repository_name }}."
63+ color=7317724
64+ fi
6065
61- - name : New Issue
62- uses : tsickert/discord-webhook@b217a69502f52803de774ded2b1ab7c282e99645 # v7.0.0
63- if : ${{ (inputs.event_name == 'issues') }}
64- with :
65- webhook-url : ${{ secrets.env_discord }}
66- avatar-url : https://avatars.githubusercontent.com/u/9919?s=200&v=4
67- embed-author-name : ${{ inputs.event_sender_login }}
68- embed-author-url : ${{ inputs.event_sender_html_url }}
69- embed-author-icon-url : ${{ inputs.event_sender_avatar_url }}
70- embed-title : ${{ inputs.event_issue_title }}
71- embed-url : ${{ inputs.event_issue_html_url }}
72- embed-description : An **issue** has been opened in ${{ inputs.repository_name }}.
73- embed-color : 14023876
66+ payload=$(jq -n \
67+ --arg author_name "${{ inputs.event_sender_login }}" \
68+ --arg author_url "${{ inputs.event_sender_html_url }}" \
69+ --arg author_icon "${{ inputs.event_sender_avatar_url }}" \
70+ --arg title "$title" \
71+ --arg url "$url" \
72+ --arg description "$description" \
73+ --argjson color "$color" \
74+ '{
75+ username: "GitHub",
76+ avatar_url: "https://avatars.githubusercontent.com/u/9919?s=200&v=4",
77+ embeds: [{
78+ author: { name: $author_name, url: $author_url, icon_url: $author_icon },
79+ title: $title,
80+ url: $url,
81+ description: $description,
82+ color: $color
83+ }]
84+ }')
7485
75- - name : New Pull Request
76- uses : tsickert/discord-webhook@b217a69502f52803de774ded2b1ab7c282e99645 # v7.0.0
77- if : ${{ (inputs.event_name == 'pull_request_target') }}
78- with :
79- webhook-url : ${{ secrets.env_discord }}
80- avatar-url : https://avatars.githubusercontent.com/u/9919?s=200&v=4
81- embed-author-name : ${{ inputs.event_sender_login }}
82- embed-author-url : ${{ inputs.event_sender_html_url }}
83- embed-author-icon-url : ${{ inputs.event_sender_avatar_url }}
84- embed-title : ${{ inputs.event_pull_request_title }}
85- embed-url : ${{ inputs.event_pull_request_html_url }}
86- embed-description : A **pull request** has been opened in ${{ inputs.repository_name }}.
87- embed-color : 7317724
86+ curl -s -X POST "${{ secrets.env_discord }}" -H "Content-Type: application/json" -d "$payload"
0 commit comments