Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 18 additions & 31 deletions .github/workflows/discord-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,17 @@ on:
pull_request:
types:
- opened
- reopened
- ready_for_review


jobs:
discord-notification:
if: >
github.event.action == 'ready_for_review' ||
(
github.event.pull_request.draft == false &&
(
github.event.action == 'opened' ||
github.event.action == 'reopened'
)
)
if: github.event.pull_request.draft == false

runs-on: ubuntu-latest

steps:
- name: Send Discord PR notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_PR_WEBHOOK }}
DISCORD_ROLE_ID: ${{ secrets.DISCORD_PR_REVIEW_ROLE }}

REPO_NAME: ${{ github.event.repository.name }}
REPO_URL: ${{ github.event.repository.html_url }}
Expand Down Expand Up @@ -73,7 +62,6 @@ jobs:
deletions = os.environ["DELETIONS"]
changed_files = os.environ["CHANGED_FILES"]

role = os.environ["DISCORD_ROLE_ID"]
webhook = os.environ["DISCORD_WEBHOOK"]
event_action = os.environ["EVENT_ACTION"]

Expand Down Expand Up @@ -118,24 +106,23 @@ jobs:
]

payload = {
"content": f"<@&{role}> — PR ready for review",
"content": "",
"allowed_mentions": {
"roles": [role],
"parse": []
},
"embeds": [
{
"title": f"🔀 {repo} #{number} — {title}",
"url": url,
"description": f"PR #{number} is ready for review.",
"author": {
"name": author,
"icon_url": avatar
},
"fields": fields
}
]
}
"parse": []
},
"embeds": [
{
"title": f"🔀 {repo} #{number} — {title}",
"url": url,
"description": f"PR #{number} has been opened.",
"author": {
"name": author,
"icon_url": avatar
},
"fields": fields
}
]
}

data = json.dumps(payload).encode("utf-8")

Expand Down