nit: Use shareable discord flow to use it from other repo (#5746)

* cleaning

* cleaning

* fix

* Update .github/workflows/discord-notification.yml

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>

---------

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
This commit is contained in:
centdix
2025-05-15 12:16:03 +02:00
committed by GitHub
parent 8c6647e0b0
commit d650aa4228
3 changed files with 64 additions and 34 deletions

View File

@@ -0,0 +1,18 @@
name: "Send discord notification when a PR is ready for review"
on:
pull_request:
types:
- opened
- ready_for_review
jobs:
call_reusable_workflow:
if: github.event.pull_request.draft == false
uses: ./.github/workflows/shareable-discord-notification.yml
with:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
secrets:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_PR_REVIEWS_WEBHOOK }}

View File

@@ -1,34 +0,0 @@
name: "Notify Discord on New PR (with Thread)"
on:
pull_request:
types:
- opened
- ready_for_review
jobs:
discord_notification:
# still guard out any drafts (just in case)
if: github.event.pull_request.draft == false
runs-on: ubicloud-standard-2
steps:
- name: Send Discord notification and start a thread
env:
WEBHOOK_URL: ${{ secrets.DISCORD_PR_REVIEWS_WEBHOOK }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
run: |
payload=$(jq -n \
--arg content "${PR_URL}" \
--arg thread "$PR_TITLE by \`${PR_AUTHOR}\`" \
'{
content: $content,
thread_name: $thread,
auto_archive_duration: 10080
}'
)
curl -H "Content-Type: application/json" \
-X POST \
--data "$payload" \
"$WEBHOOK_URL"

View File

@@ -0,0 +1,46 @@
name: "Send discord notification when a PR is ready for review"
on:
workflow_call:
inputs:
PR_TITLE:
description: "The title of the PR"
required: true
type: string
PR_URL:
description: "The URL of the PR"
required: true
type: string
PR_AUTHOR:
description: "The author of the PR"
required: true
type: string
secrets:
DISCORD_WEBHOOK_URL:
description: "Discord Webhook URL"
required: true
jobs:
send_notification:
runs-on: ubicloud-standard-2
steps:
- name: Send Discord notification and start a thread
env:
WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
PR_TITLE: ${{ inputs.PR_TITLE }}
PR_URL: ${{ inputs.PR_URL }}
PR_AUTHOR: ${{ inputs.PR_AUTHOR }}
run: |
payload=$(jq -n \
--arg content "${PR_URL}" \
--arg thread "$PR_TITLE by \`${PR_AUTHOR}\`" \
'{
content: $content,
thread_name: $thread,
auto_archive_duration: 10080
}'
)
curl -H "Content-Type: application/json" \
-X POST \
--data "$payload" \
"$WEBHOOK_URL"