Skip to content

🛠️ Refactor: SubjectsEndpoint - DRY filtering logic #410

🛠️ Refactor: SubjectsEndpoint - DRY filtering logic

🛠️ Refactor: SubjectsEndpoint - DRY filtering logic #410

Workflow file for this run

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,
});
}
}