-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added handle-issues.yml to clean up no response sections (#1903)
* Added handle-issues.yml to clean up no response sections * Added permissions to handle-issues.yml
- Loading branch information
1 parent
b905f25
commit 0ba5e39
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Remove 'No response', 'NA', and 'N/A' Sections | ||
|
||
on: | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
clean_issue_body: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
issues: write | ||
steps: | ||
- name: Remove 'No response', 'NA', and 'N/A' sections | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const issue = context.payload.issue; | ||
let body = issue.body; | ||
// Regex to match '### <Title>' followed by '_No response_', 'NA', or 'N/A', including possible spaces or newlines | ||
const noResponsePattern = /(###\s+[^\n]+\n\s*(_No response_|NA|N\/A)\s*\n?)/g; | ||
// Replace all matched sections | ||
let cleanedBody = body.replace(noResponsePattern, ''); | ||
// Update the issue body if changes were made | ||
if (cleanedBody.trim() !== body.trim()) { | ||
await github.rest.issues.update({ | ||
issue_number: issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: cleanedBody.trim() | ||
}); | ||
} |