From 29342018d43e10b25174e3544879c85046338915 Mon Sep 17 00:00:00 2001 From: tobigr Date: Sun, 15 Feb 2026 14:52:16 +0100 Subject: [PATCH] Add workflow to react on missing or ignored templates The workflow creates a comment on the issue or PR that has a missing or ignored template asking the author to use the template properly. --- .github/workflows/template-label.yml | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/template-label.yml diff --git a/.github/workflows/template-label.yml b/.github/workflows/template-label.yml new file mode 100644 index 000000000..52056a572 --- /dev/null +++ b/.github/workflows/template-label.yml @@ -0,0 +1,61 @@ +name: Template label comment + +on: + issues: + types: [labeled] + pull_request: + types: [labeled] + +permissions: + issues: write + pull-requests: write + +jobs: + comment_on_label: + name: Comment on labeled issue/PR + if: ${{ github.event.label.name == 'template-ignored' || github.event.label.name == 'template-missing' }} + runs-on: ubuntu-latest + steps: + - name: Get PR template + if: ${{ github.event.pull_request && github.event.label.name == 'template-missing' }} + run: | + set -euo pipefail + { + echo 'PR_TEMPLATE<> $GITHUB_ENV + + - name: Post comment + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const label = context.payload.label && context.payload.label.name; + if (!label) return; + const isPR = !!context.payload.pull_request; + const number = isPR ? context.payload.pull_request.number : context.payload.issue.number; + + let body = ''; + if (label === 'template-ignored') { + body = 'Please fill in the template completely or at least as much as possible. The team needs more detailed information.'; + } else if (label === 'template-missing') { + const kind = isPR ? 'PR' : 'issue'; + let template; + if (isPR) { + template = '
Raw template\n```\n' + process.env.PR_TEMPLATE + '\n```\n
'; + } else { + template = '[Bug report template](https://raw.githubusercontent.com/TeamNewPipe/NewPipe/refs/heads/dev/.github/ISSUE_TEMPLATE/bug_report.yml), [Feature request template](https://raw.githubusercontent.com/TeamNewPipe/NewPipe/refs/heads/dev/.github/ISSUE_TEMPLATE/feature_request.yml)'; + } + body = `Thank you for creating this ${kind}. Please edit your description and add the template with the information: ${template}`; + } else { + return; + } + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: number, + body + }); +