-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workflow Provided Discord Integrations (#1848)
* feat(workflows) Adding Discord integration workflows for PRs and Issues * fix(workflows) Ok let's try this * fix(workflows) Use jq to build embeds json for discord messages * fix(workflows) Removed if statement * fix(workflows) Trying a different approach to providing conditional args to embeds * fix(workflows) Fixing syntax error * fix(workflows) Remove unnecessary escaping and fix url * fix(workflows) Build all embed args upfront * fix(workflows) Don't trigger discord-pr-review on comments * fix(workflows) Fixed a duplicate args typo * chore(workflows) Add description to pr reviews, standardise footer * feat(workflows) Add a discussions discord integration * feat(workflows) Add author details to all discord messages
- Loading branch information
Showing
10 changed files
with
475 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Discord Integration - Discussion Comments | ||
on: | ||
discussion_comment: | ||
types: [created] | ||
|
||
jobs: | ||
post-to-discord: | ||
name: Post Comment To Discord | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Build Embeds JSON | ||
env: | ||
TEMPLATE: >- | ||
[{ | ||
"author": { | ||
"name": $author_name, | ||
"icon_url": $author_icon_url, | ||
"url": $author_html_url | ||
}, | ||
"title": $title, | ||
"color": 2369839, | ||
"url": $html_url, | ||
"description": $body, | ||
"footer": { | ||
"text": $repo_full_name | ||
} | ||
}] | ||
AUTHOR: ${{ github.event.sender.login }} | ||
AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} | ||
AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} | ||
TITLE: 'Comment on #${{ github.event.discussion.number }} ${{ github.event.discussion.title }}' | ||
BODY: ${{ github.event.comment.body }} | ||
HTML_URL: ${{ github.event.review.html_url }} | ||
REPO_FULL_NAME: ${{ github.event.repository.full_name }} | ||
run: | | ||
echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg body "$BODY" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV | ||
- name: Send Notification | ||
uses: Ilshidur/action-discord@0.3.2 | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_DISCUSSIONS_WEBHOOK }} | ||
DISCORD_USERNAME: 'GitHub' | ||
DISCORD_AVATAR: https://octodex.github.com/images/socialite.jpg | ||
SENDER_NAME: ${{ github.event.sender.login }} | ||
with: | ||
args: 'New comment by ${{ env.SENDER_NAME }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Discord Integration - Discussion Opened | ||
on: | ||
discussion: | ||
types: [opened] | ||
|
||
jobs: | ||
post-to-discord: | ||
name: Post Notification To Discord | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Build Embeds JSON | ||
env: | ||
TEMPLATE: >- | ||
[{ | ||
"author": { | ||
"name": $author_name, | ||
"icon_url": $author_icon_url, | ||
"url": $author_html_url | ||
}, | ||
"title": $title, | ||
"color": 3581519, | ||
"url": $html_url, | ||
"description": $description, | ||
"footer": { | ||
"text": $repo_full_name | ||
} | ||
}] | ||
AUTHOR: ${{ github.event.sender.login }} | ||
AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} | ||
AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} | ||
TITLE: '#${{ github.event.discussion.number }} ${{ github.event.discussion.title }}' | ||
HTML_URL: ${{ github.event.discussion.html_url }} | ||
DESCRIPTION: ${{ github.event.discussion.body }} | ||
REPO_FULL_NAME: ${{ github.event.repository.full_name }} | ||
run: | | ||
# This provides the env variable used by the next step | ||
# We have to do it like this to prevent any of the values screwing up the json | ||
echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg description "$DESCRIPTION" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV | ||
- name: Send Notification | ||
uses: Ilshidur/action-discord@0.3.2 | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_DISCUSSIONS_WEBHOOK }} | ||
DISCORD_USERNAME: 'GitHub' | ||
DISCORD_AVATAR: https://octodex.github.com/images/socialite.jpg | ||
SENDER_NAME: ${{ github.event.sender.login }} | ||
with: | ||
args: 'Discussion started by ${{ env.SENDER_NAME }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Discord Integration - Issue Closed | ||
on: | ||
issues: | ||
types: [closed] | ||
|
||
jobs: | ||
post-to-discord: | ||
name: Post Notification To Discord | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Build Embeds JSON | ||
env: | ||
TEMPLATE: >- | ||
[{ | ||
"author": { | ||
"name": $author_name, | ||
"icon_url": $author_icon_url, | ||
"url": $author_html_url | ||
}, | ||
"title": $title, | ||
"color": 13313073, | ||
"url": $html_url, | ||
"description": $description, | ||
"footer": { | ||
"text": $repo_full_name | ||
} | ||
}] | ||
AUTHOR: ${{ github.event.sender.login }} | ||
AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} | ||
AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} | ||
TITLE: 'Closed #${{ github.event.issue.number }} ${{ github.event.issue.title }}' | ||
HTML_URL: ${{ github.event.issue.html_url }} | ||
DESCRIPTION: ${{ github.event.issue.body }} | ||
REPO_FULL_NAME: ${{ github.event.repository.full_name }} | ||
run: | | ||
# This provides the env variable used by the next step | ||
# We have to do it like this to prevent any of the values screwing up the json | ||
echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg description "$DESCRIPTION" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV | ||
- name: Send Notification | ||
uses: Ilshidur/action-discord@0.3.2 | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_ISSUES_WEBHOOK }} | ||
DISCORD_USERNAME: 'GitHub' | ||
DISCORD_AVATAR: https://octodex.github.com/images/original.png | ||
SENDER_NAME: ${{ github.event.sender.login }} | ||
with: | ||
args: 'Issue closed by ${{ env.SENDER_NAME }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Discord Integration - Issue Comments | ||
on: | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
post-to-discord: | ||
name: Post Comment To Discord | ||
runs-on: ubuntu-latest | ||
if: ${{ !github.event.issue.pull_request }} | ||
steps: | ||
- name: Build Embeds JSON | ||
env: | ||
TEMPLATE: >- | ||
[{ | ||
"author": { | ||
"name": $author_name, | ||
"icon_url": $author_icon_url, | ||
"url": $author_html_url | ||
}, | ||
"title": $title, | ||
"color": 2369839, | ||
"url": $html_url, | ||
"description": $body, | ||
"footer": { | ||
"text": $repo_full_name | ||
} | ||
}] | ||
AUTHOR: ${{ github.event.sender.login }} | ||
AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} | ||
AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} | ||
TITLE: 'Comment on #${{ github.event.issue.number }} ${{ github.event.issue.title }}' | ||
BODY: ${{ github.event.comment.body }} | ||
HTML_URL: ${{ github.event.review.html_url }} | ||
REPO_FULL_NAME: ${{ github.event.repository.full_name }} | ||
run: | | ||
echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg body "$BODY" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV | ||
- name: Send Notification | ||
uses: Ilshidur/action-discord@0.3.2 | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_ISSUES_WEBHOOK }} | ||
DISCORD_USERNAME: 'GitHub' | ||
DISCORD_AVATAR: https://octodex.github.com/images/original.png | ||
SENDER_NAME: ${{ github.event.sender.login }} | ||
with: | ||
args: 'New comment by ${{ env.SENDER_NAME }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Discord Integration - Issue Opened | ||
on: | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
post-to-discord: | ||
name: Post Notification To Discord | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Build Embeds JSON | ||
env: | ||
TEMPLATE: >- | ||
[{ | ||
"author": { | ||
"name": $author_name, | ||
"icon_url": $author_icon_url, | ||
"url": $author_html_url | ||
}, | ||
"title": $title, | ||
"color": 3581519, | ||
"url": $html_url, | ||
"description": $description, | ||
"footer": { | ||
"text": $repo_full_name | ||
} | ||
}] | ||
AUTHOR: ${{ github.event.sender.login }} | ||
AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} | ||
AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} | ||
TITLE: '#${{ github.event.issue.number }} ${{ github.event.issue.title }}' | ||
HTML_URL: ${{ github.event.issue.html_url }} | ||
DESCRIPTION: ${{ github.event.issue.body }} | ||
REPO_FULL_NAME: ${{ github.event.repository.full_name }} | ||
run: | | ||
# This provides the env variable used by the next step | ||
# We have to do it like this to prevent any of the values screwing up the json | ||
echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg description "$DESCRIPTION" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV | ||
- name: Send Notification | ||
uses: Ilshidur/action-discord@0.3.2 | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_ISSUES_WEBHOOK }} | ||
DISCORD_USERNAME: 'GitHub' | ||
DISCORD_AVATAR: https://octodex.github.com/images/original.png | ||
SENDER_NAME: ${{ github.event.sender.login }} | ||
with: | ||
args: 'Issue opened by ${{ env.SENDER_NAME }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Discord Integration - PR Closed | ||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
post-to-discord: | ||
name: Post Notification To Discord | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Build Merged Args | ||
if: ${{ github.event.pull_request.merged }} | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
PR_TITLE: ${{ github.event.pull_request.title }} | ||
SENDER_NAME: ${{ github.event.sender.login }} | ||
run: | | ||
echo "TITLE=Merged #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV | ||
echo "COLOR=7291585" >> $GITHUB_ENV | ||
echo "MESSAGE_ARGS=PR merged by $SENDER_NAME'" >> $GITHUB_ENV | ||
- name: Build Closed Args | ||
if: ${{ !github.event.pull_request.merged }} | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
PR_TITLE: ${{ github.event.pull_request.title }} | ||
SENDER_NAME: ${{ github.event.sender.login }} | ||
run: | | ||
echo "TITLE=Closed (Without Merge) #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV | ||
echo "COLOR=13313073" >> $GITHUB_ENV | ||
echo "MESSAGE_ARGS=PR closed by $SENDER_NAME" >> $GITHUB_ENV | ||
- name: Build Embeds JSON | ||
env: | ||
TEMPLATE: >- | ||
[{ | ||
"author": { | ||
"name": $author_name, | ||
"icon_url": $author_icon_url, | ||
"url": $author_html_url | ||
}, | ||
"title": $title, | ||
"color": $color, | ||
"url": $html_url, | ||
"footer": { | ||
"text": $repo_full_name | ||
} | ||
}] | ||
AUTHOR: ${{ github.event.sender.login }} | ||
AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} | ||
AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} | ||
HTML_URL: ${{ github.event.pull_request.html_url }} | ||
REPO_FULL_NAME: ${{ github.event.repository.full_name }} | ||
run: | | ||
echo "DISCORD_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg color "$COLOR" --arg html_url "$HTML_URL" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV | ||
- name: Send Notification | ||
uses: Ilshidur/action-discord@0.3.2 | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_PRS_WEBHOOK }} | ||
DISCORD_USERNAME: 'GitHub' | ||
DISCORD_AVATAR: https://octodex.github.com/images/inspectocat.jpg | ||
with: | ||
args: ${{ env.MESSAGE_ARGS }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Discord Integration - PR Comments | ||
on: | ||
pull_request_review_comment: | ||
types: [created] | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
post-to-discord: | ||
name: Post Notification To Discord | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.pull_request || github.event.issue.pull_request }} | ||
steps: | ||
- name: Capture Body With Diff | ||
if: ${{ github.event.comment.diff_hunk }} | ||
env: | ||
BASE_DIFF_HUNK: ${{ github.event.comment.diff_hunk }} | ||
BODY: ${{ github.event.comment.body }} | ||
run: echo "BODY=\`\`\`$BASE_DIFF_HUNK\`\`\`\n$BODY" >> $GITHUB_ENV | ||
- name: Build PR Review Comment Args | ||
if: ${{ github.event.pull_request }} | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
PR_TITLE: ${{ github.event.pull_request.title }} | ||
run: | | ||
echo "TITLE=Comment on #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV | ||
- name: Build PR Issue Comment Args | ||
if: ${{ github.event.issue.pull_request }} | ||
env: | ||
PR_NUMBER: ${{ github.event.issue.number }} | ||
PR_TITLE: ${{ github.event.issue.title }} | ||
run: | | ||
echo "TITLE=Comment on #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV | ||
- name: Build Embeds JSON | ||
env: | ||
TEMPLATE: >- | ||
[{ | ||
"author": { | ||
"name": $author_name, | ||
"icon_url": $author_icon_url, | ||
"url": $author_html_url | ||
}, | ||
"title": $title, | ||
"color": 2369839, | ||
"url": $html_url, | ||
"description": $body, | ||
"footer": { | ||
"text": $repo_full_name | ||
} | ||
}] | ||
AUTHOR: ${{ github.event.sender.login }} | ||
AUTHOR_ICON_URL: ${{ github.event.sender.avatar_url }} | ||
AUTHOR_HTML_URL: ${{ github.event.sender.html_url }} | ||
HTML_URL: ${{ github.event.review.html_url }} | ||
REPO_FULL_NAME: ${{ github.event.repository.full_name }} | ||
run: | | ||
echo "PARTIAL_EMBEDS=$(jq -nc --arg author_name "$AUTHOR" --arg author_icon_url "$AUTHOR_ICON_URL" --arg author_html_url "$AUTHOR_HTML_URL" --arg title "$TITLE" --arg html_url "$HTML_URL" --arg body "$BODY" --arg repo_full_name "$REPO_FULL_NAME" "$TEMPLATE")" >> $GITHUB_ENV | ||
- name: Send Notification | ||
uses: Ilshidur/action-discord@0.3.2 | ||
env: | ||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_PRS_WEBHOOK }} | ||
DISCORD_USERNAME: 'GitHub' | ||
DISCORD_AVATAR: https://octodex.github.com/images/inspectocat.jpg | ||
SENDER_NAME: ${{ github.event.sender.login }} | ||
with: | ||
args: 'New comment by ${{ env.SENDER_NAME }}' |
Oops, something went wrong.