🛠️ Refactor: Endpoints - Collapse list logic and remove duplication #406
Workflow file for this run
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: Sanitize PR Links | |
| on: | |
| pull_request_target: | |
| types: [opened, edited, synchronize] | |
| permissions: | |
| pull-requests: write | |
| jobs: | |
| sanitize: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = context.payload.pull_request; | |
| if (!pr) return; | |
| const regex = /https:\/\/chatgpt\.com\/codex\/\S+/g; | |
| const body = pr.body || ''; | |
| const sanitizedBody = body.replace(regex, ''); | |
| if (sanitizedBody !== body) { | |
| await github.rest.pulls.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: pr.number, | |
| body: sanitizedBody, | |
| }); | |
| } | |
| const comments = await github.paginate( | |
| github.rest.issues.listComments, | |
| { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| per_page: 100, | |
| } | |
| ); | |
| for (const comment of comments) { | |
| if (!comment.body) continue; | |
| const sanitizedComment = comment.body.replace(regex, ''); | |
| if (sanitizedComment !== comment.body) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: comment.id, | |
| body: sanitizedComment, | |
| }); | |
| } | |
| } |