Skip to content

Data Cartouche Style #3956

Data Cartouche Style

Data Cartouche Style #3956

name: Discord Integration - PR Opened
on:
pull_request:
types: [opened, ready_for_review]
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.draft }}
steps:
- name: Build Embeds JSON
env:
TEMPLATE: >-
[{
"author": {
"name": $author_name,
"icon_url": $author_icon_url,
"url": $author_html_url
},
"title": $title,
"color": 7291585,
"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.pull_request.number }} ${{ github.event.pull_request.title }}'
HTML_URL: ${{ github.event.pull_request.html_url }}
DESCRIPTION: ${{ github.event.pull_request.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:
BODY: ${{ github.event.pull_request.body }}
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: 'PR opened by ${{ env.SENDER_NAME }}'