hande-issues.yml 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. name: Remove 'No response', 'NA', and 'N/A' Sections
  2. on:
  3. issues:
  4. types: [opened]
  5. jobs:
  6. clean_issue_body:
  7. runs-on: ubuntu-latest
  8. permissions:
  9. issues: write
  10. steps:
  11. - name: Remove 'No response', 'NA', and 'N/A' sections
  12. uses: actions/github-script@v6
  13. with:
  14. github-token: ${{ secrets.GITHUB_TOKEN }}
  15. script: |
  16. const issue = context.payload.issue;
  17. let body = issue.body;
  18. // Regex to match '### <Title>' followed by '_No response_', 'NA', or 'N/A', including possible spaces or newlines
  19. const noResponsePattern = /(###\s+[^\n]+\n\s*(_No response_|NA|N\/A)\s*\n?)/g;
  20. // Replace all matched sections
  21. let cleanedBody = body.replace(noResponsePattern, '');
  22. // Update the issue body if changes were made
  23. if (cleanedBody.trim() !== body.trim()) {
  24. await github.rest.issues.update({
  25. issue_number: issue.number,
  26. owner: context.repo.owner,
  27. repo: context.repo.repo,
  28. body: cleanedBody.trim()
  29. });
  30. }