|
| 1 | +name: 🤖 Auto Reply to Issues & PRs |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [opened, reopened] |
| 6 | + pull_request: |
| 7 | + types: [opened, reopened] |
| 8 | + |
| 9 | +permissions: |
| 10 | + issues: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + auto-comment: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: 🧠 Auto Comment |
| 19 | + uses: actions/github-script@v7 |
| 20 | + with: |
| 21 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 22 | + script: | |
| 23 | + const eventName = context.eventName; |
| 24 | + const repo = context.repo; |
| 25 | +
|
| 26 | + if (eventName === "issues") { |
| 27 | + const user = context.payload.issue.user.login; |
| 28 | + const message = `👋 Hi @${user}! |
| 29 | + Thanks for opening an issue in **MyCMD**. |
| 30 | + We’ll review it soon — meanwhile, please ensure logs and reproduction steps are clear.`; |
| 31 | +
|
| 32 | + await github.rest.issues.createComment({ |
| 33 | + owner: repo.owner, |
| 34 | + repo: repo.repo, |
| 35 | + issue_number: context.issue.number, |
| 36 | + body: message |
| 37 | + }); |
| 38 | +
|
| 39 | + await github.rest.reactions.createForIssue({ |
| 40 | + owner: repo.owner, |
| 41 | + repo: repo.repo, |
| 42 | + issue_number: context.issue.number, |
| 43 | + content: "tada" |
| 44 | + }); |
| 45 | + } |
| 46 | +
|
| 47 | + if (eventName === "pull_request") { |
| 48 | + const user = context.payload.pull_request.user.login; |
| 49 | + const message = `🚀 Hi @${user}! |
| 50 | + Thank you for contributing to **MyCMD**. |
| 51 | + A maintainer will review your PR shortly. 🎉`; |
| 52 | +
|
| 53 | + await github.rest.issues.createComment({ |
| 54 | + owner: repo.owner, |
| 55 | + repo: repo.repo, |
| 56 | + issue_number: context.payload.pull_request.number, |
| 57 | + body: message |
| 58 | + }); |
| 59 | +
|
| 60 | + await github.rest.reactions.createForIssue({ |
| 61 | + owner: repo.owner, |
| 62 | + repo: repo.repo, |
| 63 | + issue_number: context.payload.pull_request.number, |
| 64 | + content: "rocket" |
| 65 | + }); |
| 66 | + } |
0 commit comments