|
| 1 | +name: PR Automation Comments |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: [labeled] |
| 5 | + |
| 6 | +permissions: |
| 7 | + pull-requests: write |
| 8 | + |
| 9 | +jobs: |
| 10 | + comment-on-breaking-change: |
| 11 | + if: contains(github.event.label.name, 'breaking change') |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Comment on PR |
| 15 | + uses: actions/github-script@v7 |
| 16 | + with: |
| 17 | + script: | |
| 18 | + const { data: comments } = await github.rest.issues.listComments({ |
| 19 | + owner: context.repo.owner, |
| 20 | + repo: context.repo.repo, |
| 21 | + issue_number: context.issue.number, |
| 22 | + }); |
| 23 | +
|
| 24 | + // Check if we've already commented about breaking changes |
| 25 | + const botComment = comments.find(comment => |
| 26 | + comment.user.login === 'github-actions[bot]' && |
| 27 | + comment.body.includes('⚠️ Breaking Change Documentation Required') |
| 28 | + ); |
| 29 | +
|
| 30 | + if (!botComment) { |
| 31 | + const commentBody = [ |
| 32 | + "## ⚠️ Breaking Change Documentation Required", |
| 33 | + "", |
| 34 | + "This PR has been labeled as a **breaking change**. Please ensure you provide the following information:", |
| 35 | + "", |
| 36 | + "### Migration Notes Required", |
| 37 | + "Please add detailed migration notes to help users understand:", |
| 38 | + "- What is changing and why", |
| 39 | + "- How to update their code/configuration", |
| 40 | + "- Any alternative approaches if applicable", |
| 41 | + "- Code examples showing before/after usage", |
| 42 | + "", |
| 43 | + "### Checklist", |
| 44 | + "- [ ] Migration notes added to the PR description", |
| 45 | + "- [ ] Breaking change is documented in the changelog entry for the next release", |
| 46 | + "- [ ] Consider if this change requires a major version bump", |
| 47 | + "", |
| 48 | + "Your migration notes will be included in the release notes to help users upgrade smoothly. The more detailed and helpful they are, the better the user experience will be.", |
| 49 | + "", |
| 50 | + "---", |
| 51 | + "*This comment was automatically generated because the `breaking change` label was applied to this PR.*" |
| 52 | + ].join("\n"); |
| 53 | +
|
| 54 | + await github.rest.issues.createComment({ |
| 55 | + owner: context.repo.owner, |
| 56 | + repo: context.repo.repo, |
| 57 | + issue_number: context.issue.number, |
| 58 | + body: commentBody |
| 59 | + }); |
| 60 | + } |
| 61 | +
|
| 62 | + comment-on-deprecation: |
| 63 | + if: contains(github.event.label.name, 'deprecation') |
| 64 | + runs-on: ubuntu-latest |
| 65 | + steps: |
| 66 | + - name: Comment on PR |
| 67 | + uses: actions/github-script@v7 |
| 68 | + with: |
| 69 | + script: | |
| 70 | + const { data: comments } = await github.rest.issues.listComments({ |
| 71 | + owner: context.repo.owner, |
| 72 | + repo: context.repo.repo, |
| 73 | + issue_number: context.issue.number, |
| 74 | + }); |
| 75 | +
|
| 76 | + // Check if we've already commented about deprecation |
| 77 | + const botComment = comments.find(comment => |
| 78 | + comment.user.login === 'github-actions[bot]' && |
| 79 | + comment.body.includes('📋 Deprecation Notice') |
| 80 | + ); |
| 81 | +
|
| 82 | + if (!botComment) { |
| 83 | + const commentBody = [ |
| 84 | + "## 📋 Deprecation Notice", |
| 85 | + "", |
| 86 | + "This PR has been labeled as a **deprecation**. Please ensure you provide the following information:", |
| 87 | + "", |
| 88 | + "### 📝 Deprecation Details Required", |
| 89 | + "Please add details to help users understand:", |
| 90 | + "- What is being deprecated and why", |
| 91 | + "- What should be used instead (if applicable)", |
| 92 | + "- Timeline for removal (if known)", |
| 93 | + "- Any migration guidance", |
| 94 | + "", |
| 95 | + "### 📋 Checklist", |
| 96 | + "- [ ] Deprecation details added to the PR description", |
| 97 | + "- [ ] Deprecation is documented in the changelog entry for the next release", |
| 98 | + "- [ ] Consider adding deprecation warnings in code/documentation", |
| 99 | + "", |
| 100 | + "Your deprecation notes will be included in the release notes to help users prepare for future changes.", |
| 101 | + "", |
| 102 | + "---", |
| 103 | + "*This comment was automatically generated because the `deprecation` label was applied to this PR.*" |
| 104 | + ].join("\n"); |
| 105 | +
|
| 106 | + await github.rest.issues.createComment({ |
| 107 | + owner: context.repo.owner, |
| 108 | + repo: context.repo.repo, |
| 109 | + issue_number: context.issue.number, |
| 110 | + body: commentBody |
| 111 | + }); |
| 112 | + } |
0 commit comments