Refactor questions/[id].tsx - 527-line monolith combining 8 responsibilities #49
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 Comment on Issue | |
| on: | |
| issues: | |
| types: [opened] | |
| permissions: | |
| issues: write | |
| jobs: | |
| comment: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Add Comment to Issue | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| try { | |
| const issueNumber = context.issue.number; | |
| const issueAuthor = context.payload.issue.user.login; | |
| const commentBody = ` #### 🚀 Thanks for Helping Improve CanonForces! | |
| We'll review it as soon as possible. We truly appreciate your contributions to **CanonForces**! ⚔️✨ | |
| > ✅ Before working on a PR, please: | |
| > - Read our [README.md](https://github.com/OpenLake/canonforces/blob/main/README.md), [CONTRIBUTING.md](https://github.com/OpenLake/canonforces/blob/main/CONTRIBUTING.md). | |
| > - Wait until the issue is **assigned** to you before starting a PR. | |
| > - Discuss your approach if you're unsure, we're happy to help! | |
| 💬 Need quick support or want to discuss ideas? | |
| Join our Discord 👉 [CanonForces Discord](https://discord.gg/4YnYtVeF) | |
| Thanks again, @${issueAuthor}! 🎉`; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| body: commentBody | |
| }); | |
| console.log('✅ Auto comment added successfully!'); | |
| } catch (error) { | |
| console.error('❌ Error adding comment to issue:', error); | |
| core.setFailed(`Failed to add comment: ${error.message}`); | |
| } |