main page revise #12
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: Notify Discord on PR Events | |
on: | |
pull_request: | |
types: [opened, closed] | |
jobs: | |
notify-discord: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Send Discord notification | |
env: | |
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
run: | | |
if [[ "${{ github.event.action }}" == "opened" ]]; then | |
MESSAGE="π’ A new pull request has been opened in \`${{ github.repository }}\`" | |
MESSAGE+=" by \`${{ github.actor }}\`.\n" | |
MESSAGE+="π [PR #${{ github.event.number }} - ${{ github.event.pull_request.title }}]" | |
MESSAGE+="(${{ github.event.pull_request.html_url }})" | |
elif [[ "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" == "true" ]]; then | |
MESSAGE="β Pull request \`${{ github.event.pull_request.title }}\` in \`${{ github.repository }}\`" | |
MESSAGE+=" has been merged by \`${{ github.actor }}\`.\n" | |
MESSAGE+="π [PR #${{ github.event.number }}]" | |
MESSAGE+="(${{ github.event.pull_request.html_url }})" | |
elif [[ "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" != "true" ]]; then | |
MESSAGE="β Pull request \`${{ github.event.pull_request.title }}\` in \`${{ github.repository }}\`" | |
MESSAGE+=" has been closed without merging by \`${{ github.actor }}\`.\n" | |
MESSAGE+="π [PR #${{ github.event.number }}]" | |
MESSAGE+="(${{ github.event.pull_request.html_url }})" | |
else | |
exit 0; # Exit for any other PR events (not interested) | |
fi | |
curl -H "Content-Type: application/json" \ | |
-d "{\"content\": \"$MESSAGE\"}" \ | |
$DISCORD_WEBHOOK_URL |