|
60 | 60 | });
|
61 | 61 | await Promise.all(requests);
|
62 | 62 | }
|
| 63 | +
|
| 64 | + - name: Comment for mapping-kit changes |
| 65 | + uses: actions/github-script@v7 |
| 66 | + env: |
| 67 | + labelsToAdd: '${{ steps.compute-labels.outputs.add }}' |
| 68 | + labelsToRemove: '${{ steps.compute-labels.outputs.remove }}' |
| 69 | + with: |
| 70 | + script: | |
| 71 | + const { labelsToAdd, labelsToRemove, DRY_RUN } = process.env |
| 72 | + const shouldAddComment = labelsToAdd.length > 0 && labelsToAdd.split(",").some(x=>x.includes("mappingkit")) |
| 73 | + const shouldRemoveComment = labelsToRemove.length > 0 && labelsToRemove.split(",").some(x=>x.includes("mappingkit")) |
| 74 | + // Get the list of comments on the PR |
| 75 | + const response = await github.rest.issues.listComments({ |
| 76 | + issue_number: context.issue.number, |
| 77 | + owner: context.repo.owner, |
| 78 | + repo: context.repo.repo |
| 79 | + }) |
| 80 | + const mappingKitComment = response.data.find(comment => comment.body.includes('mapping-kit go')) |
| 81 | + if(shouldAddComment){ |
| 82 | + if (mappingKitComment) { |
| 83 | + console.log('Already commented on this PR') |
| 84 | + return |
| 85 | + } |
| 86 | + // Add comment to the PR |
| 87 | + await github.rest.issues.createComment({ |
| 88 | + issue_number: context.issue.number, |
| 89 | + owner: context.repo.owner, |
| 90 | + repo: context.repo.repo, |
| 91 | + body: `This PR makes changes to mapping-kit. Please ensure that the changes are reflected in the [mapping-kit go](https://github.com/segmentio/mapping-kit) library as well and link the PR in description.` |
| 92 | + }) |
| 93 | + } |
| 94 | + if(shouldRemoveComment) { |
| 95 | + if (!mappingKitComment) { |
| 96 | + console.log('No mapping-kit comment to remove') |
| 97 | + return |
| 98 | + } |
| 99 | + // Remove comment from the PR |
| 100 | + await github.rest.issues.deleteComment({ |
| 101 | + comment_id: mappingKitComment.id, |
| 102 | + owner: context.repo.owner, |
| 103 | + repo: context.repo.repo |
| 104 | + }) |
| 105 | + } |
0 commit comments