Skip to content

Refactor ContextMenuWrapper #8722

Refactor ContextMenuWrapper

Refactor ContextMenuWrapper #8722

name: Discord Integration - PR Comments
on:
pull_request_review_comment:
types: [created]
issue_comment:
types: [created]
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.pull_request || github.event.issue.pull_request }}
steps:
- 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
if: ${{ github.event.sender.login != 'relativeci[bot]' }}
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 }}
BODY: ${{ github.event.comment.body }}
HTML_URL: ${{ github.event.comment.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
if: ${{ github.event.sender.login != 'relativeci[bot]' }}
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 }}'