Discord Integration - PR Review #12846
Workflow file for this run
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
name: Discord Integration - PR Review | |
on: | |
pull_request_review: | |
types: [submitted] | |
permissions: | |
actions: none | |
checks: none | |
contents: none | |
deployments: none | |
id-token: none | |
issues: none | |
packages: none | |
pages: none | |
pull-requests: none | |
repository-projects: none | |
security-events: none | |
statuses: none | |
jobs: | |
post-to-discord: | |
name: Post Notification To Discord | |
timeout-minutes: 5 | |
runs-on: ubuntu-latest | |
if: ${{ github.event.review.state == 'approved' || github.event.review.state == 'changes_requested' }} | |
steps: | |
- name: Build Approval Args | |
if: ${{ github.event.review.state == 'approved' }} | |
env: | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
PR_TITLE: ${{ github.event.pull_request.title }} | |
SENDER_NAME: ${{ github.event.sender.login }} | |
run: | | |
echo "TITLE=Approved #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV | |
echo "COLOR=3581519" >> $GITHUB_ENV | |
echo "MESSAGE_ARGS=PR approved by $SENDER_NAME" >> $GITHUB_ENV | |
- name: Build Changes Requested Args | |
if: ${{ github.event.review.state == 'changes_requested' }} | |
env: | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
PR_TITLE: ${{ github.event.pull_request.title }} | |
SENDER_NAME: ${{ github.event.sender.login }} | |
run: | | |
echo "TITLE=Changes Requested #$PR_NUMBER $PR_TITLE" >> $GITHUB_ENV | |
echo "COLOR=13313073" >> $GITHUB_ENV | |
echo "MESSAGE_ARGS=Changes requested 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, | |
"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 }} | |
HTML_URL: ${{ github.event.review.html_url }} | |
DESCRIPTION: ${{ github.event.review.body }} | |
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 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_PRS_WEBHOOK }} | |
DISCORD_USERNAME: 'GitHub' | |
DISCORD_AVATAR: https://octodex.github.com/images/inspectocat.jpg | |
with: | |
args: ${{ env.MESSAGE_ARGS }} |