From 6dd479ccdde115821504fd4ddbf04cadd2e631b6 Mon Sep 17 00:00:00 2001 From: kaedeek Date: Sat, 18 Oct 2025 02:24:17 +0900 Subject: [PATCH] github.yml add --- .github/workflows/github.yml | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/github.yml diff --git a/.github/workflows/github.yml b/.github/workflows/github.yml new file mode 100644 index 0000000..0f2318f --- /dev/null +++ b/.github/workflows/github.yml @@ -0,0 +1,50 @@ +name: Discord Pull Request Notification + +on: + pull_request: + types: [opened, closed, reopened, assigned, review_requested] + +jobs: + send_notification: + runs-on: ubuntu-latest + steps: + - name: Send Discord Notification + run: | + EVENT="${{ github.event.action }}" + PR_NUMBER="${{ github.event.pull_request.number }}" + PR_TITLE="${{ github.event.pull_request.title }}" + PR_URL="${{ github.event.pull_request.html_url }}" + USER="${{ github.actor }}" + + MESSAGE="" + + case "$EVENT" in + opened) + MESSAGE="📢 Pull Request #${PR_NUMBER} has been created! by $USER\nTitle: $PR_TITLE\nURL: $PR_URL" + ;; + closed) + if ${{ github.event.pull_request.merged }}; then + MESSAGE="🎉 Pull Request #${PR_NUMBER} has been merged! by $USER\nTitle: $PR_TITLE\nURL: $PR_URL" + else + MESSAGE="❌ Pull Request #${PR_NUMBER} has been closed! by $USER\nTitle: $PR_TITLE\nURL: $PR_URL" + fi + ;; + reopened) + MESSAGE="🔄 Pull Request #${PR_NUMBER} has been reopened! by $USER\nTitle: $PR_TITLE\nURL: $PR_URL" + ;; + assigned) + MESSAGE="🙋 Pull Request #${PR_NUMBER} has been assigned to $USER!\nTitle: $PR_TITLE\nURL: $PR_URL" + ;; + review_requested) + REVIEWER="${{ github.event.requested_reviewers.*.login }}" + MESSAGE="👀 Review for Pull Request #${PR_NUMBER} has been requested from $REVIEWER! by $USER\nTitle: $PR_TITLE\nURL: $PR_URL" + ;; + *) + MESSAGE="Unknown pull request event: $EVENT" + ;; + esac + + curl -X POST \ + -H "Content-Type: application/json" \ + -d "{\"content\": \"$MESSAGE\"}" \ + ${{ secrets.DISCORD_WEBHOOK }}