Improve auto-reply messages in GitHub Actions #3
This file contains hidden or 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: 🤖 Auto Reply to Issues & PRs | ||
| on: | ||
| issues: | ||
| types: [opened, reopened] | ||
| pull_request: | ||
| types: [opened, reopened] | ||
| permissions: | ||
| issues: write | ||
| pull-requests: write | ||
| jobs: | ||
| auto-comment: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: 🧠 Auto Comment | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const eventName = context.eventName; | ||
| const repo = context.repo; | ||
| const footer = ` | ||
| --- | ||
| 🌐 **Stay Connected with the MyCMD Community:** | ||
| - 💻 [Website](https://Drive-for-java.github.io) | ||
| - 💬 [Discord Server](https://discord.gg/MYdZbvR5gC) | ||
| - 📱 [WhatsApp Channel](https://whatsapp.com/channel/0029VbAsOiM8KMqmrdpdUG2W) | ||
| Thank you for being part of **Drive for Java 🚗☕** | ||
| `; | ||
| if (eventName === "issues") { | ||
| const user = context.payload.issue.user.login; | ||
| const message = `👋 Hi @${user}! | ||
| Thank you for opening an issue in **MyCMD**. | ||
| Our maintainers will review it soon. Please make sure your report includes: | ||
| - ✅ Clear reproduction steps | ||
| - 📋 Logs or stack traces (if applicable) | ||
| - 🧠 Details about your environment (Java version, OS, etc.) | ||
| This helps us fix and improve faster!${footer}`; | ||
| await github.rest.issues.createComment({ | ||
| owner: repo.owner, | ||
| repo: repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: message | ||
| }); | ||
| await github.rest.reactions.createForIssue({ | ||
| owner: repo.owner, | ||
| repo: repo.repo, | ||
| issue_number: context.issue.number, | ||
| content: "tada" | ||
| }); | ||
| } | ||
| if (eventName === "pull_request") { | ||
| const user = context.payload.pull_request.user.login; | ||
| const message = `🚀 Hi @${user}! | ||
| Thank you for contributing to **MyCMD** 🎉 | ||
| Your pull request has been received and will be reviewed shortly by our maintainers. | ||
| Meanwhile, please ensure: | ||
| - 🧱 Your code passes CI checks | ||
| - 📖 You’ve updated docs or comments if needed | ||
| - 🧩 You’ve tested it locally | ||
| We appreciate your efforts to make MyCMD better!${footer}`; | ||
| await github.rest.issues.createComment({ | ||
| owner: repo.owner, | ||
| repo: repo.repo, | ||
| issue_number: context.payload.pull_request.number, | ||
| body: message | ||
| }); | ||
| await github.rest.reactions.createForIssue({ | ||
| owner: repo.owner, | ||
| repo: repo.repo, | ||
| issue_number: context.payload.pull_request.number, | ||
| content: "rocket" | ||
| }); | ||
| } | ||