From 0bf7708f61cea0b7d0bcf866da0ccf923a72dd62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Korbinian=20B=C3=B6sl?= Date: Fri, 21 Nov 2025 15:10:44 +0100 Subject: [PATCH 1/8] PR checklist GH action closes #1742 --- .github/workflows/PrChecklist.yml | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/PrChecklist.yml diff --git a/.github/workflows/PrChecklist.yml b/.github/workflows/PrChecklist.yml new file mode 100644 index 000000000..7c1666c22 --- /dev/null +++ b/.github/workflows/PrChecklist.yml @@ -0,0 +1,54 @@ +name: Add Page PR Checklist + +on: + pull_request_review: + types: [submitted] + +jobs: + add_template: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Install the GH cli + uses: ksivamuthu/actions-setup-gh-cli@v3 + with: + version: 2.83.0 + + - name: Check Modified Files + id: check_files + run: | + # Get the changed files in the pull request + CHANGED_FILES=$(gh pr diff ${{ github.event.pull_request.number }} --name-only) + if echo "$CHANGED_FILES" | grep -qE '^pages/'; then + echo "TRUE" >> $GITHUB_ENV + else + echo "FALSE" >> $GITHUB_ENV + fi + + - name: Parse Checklist + id: parse_checklist + if: ${{ env.is_pages_changed == 'TRUE' }} + run: | + # Read the checklist file from the repository + CHECKLIST=$(sed -E 's/^[0-9]+\.\s+-?/- [ ] /' pages/contribute/editors_checklist.md) + echo "CHECKLIST=$CHECKLIST" >> $GITHUB_ENV + + - name: Add Review Comment + if: env.CHECKLIST != '' + uses: actions/github-script@v6 + with: + script: | + const checklist = process.env.CHECKLIST; + const template = `### Review Checklist\n\n${checklist}\n\nPlease refer to the complete [editor's checklist](https://github.com/elixir-europe/rdmkit/edit/master/pages/contribute/editors_checklist.md) for details.`; + const prNumber = context.payload.pull_request.number; + const owner = context.payload.pull_request.head.repo.owner.login; // Get code owner + const repo = context.payload.pull_request.head.repo.name; + + await github.pulls.createReviewComment({ + owner: owner, + repo: repo, + pull_number: prNumber, + body: template, + }); From 0af9d78dbeabfb66bc06b1f46ddb22f0e6a425fb Mon Sep 17 00:00:00 2001 From: Bert Droesbeke <44875756+bedroesb@users.noreply.github.com> Date: Fri, 21 Nov 2025 23:53:35 +0100 Subject: [PATCH 2/8] Rename PrChecklist.yml to pr-checklist.yml More similar to other scripts --- .github/workflows/{PrChecklist.yml => pr-checklist.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{PrChecklist.yml => pr-checklist.yml} (100%) diff --git a/.github/workflows/PrChecklist.yml b/.github/workflows/pr-checklist.yml similarity index 100% rename from .github/workflows/PrChecklist.yml rename to .github/workflows/pr-checklist.yml From 0d2283e8d98904423cbc1129b81271b5b70d2e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Korbinian=20B=C3=B6sl?= Date: Mon, 24 Nov 2025 10:21:32 +0100 Subject: [PATCH 3/8] Update .github/workflows/pr-checklist.yml Co-authored-by: Bert Droesbeke <44875756+bedroesb@users.noreply.github.com> --- .github/workflows/pr-checklist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index 7c1666c22..bf2b2096c 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -1,4 +1,4 @@ -name: Add Page PR Checklist +name: Add editorial checklist upon review on: pull_request_review: From c094cc9065881954375ccc7824a635a4af7704b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Korbinian=20B=C3=B6sl?= Date: Mon, 24 Nov 2025 10:21:36 +0100 Subject: [PATCH 4/8] Update .github/workflows/pr-checklist.yml Co-authored-by: Bert Droesbeke <44875756+bedroesb@users.noreply.github.com> --- .github/workflows/pr-checklist.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index bf2b2096c..32ccc015f 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install the GH cli uses: ksivamuthu/actions-setup-gh-cli@v3 From 485a5e73d141b6714f567eeb70f8d6ceeeb774e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Korbinian=20B=C3=B6sl?= Date: Mon, 24 Nov 2025 10:29:40 +0100 Subject: [PATCH 5/8] Set GH_TOKEN in PR checklist workflow Add GH_TOKEN environment variable for file check. --- .github/workflows/pr-checklist.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index 32ccc015f..e060a3c35 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -18,6 +18,8 @@ jobs: - name: Check Modified Files id: check_files + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Get the changed files in the pull request CHANGED_FILES=$(gh pr diff ${{ github.event.pull_request.number }} --name-only) From bfcdf8306c8dad2bdd757547f56f8f4ad44d70b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Korbinian=20B=C3=B6sl?= Date: Tue, 25 Nov 2025 09:18:23 +0100 Subject: [PATCH 6/8] Remove CLI setup --- .github/workflows/pr-checklist.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index e060a3c35..7557cf9ed 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -11,11 +11,6 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Install the GH cli - uses: ksivamuthu/actions-setup-gh-cli@v3 - with: - version: 2.83.0 - - name: Check Modified Files id: check_files env: From 7391bf5c5552e460f36166cad511266987da75ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Korbinian=20B=C3=B6sl?= Date: Tue, 25 Nov 2025 09:23:33 +0100 Subject: [PATCH 7/8] GITHUB output and variable fix --- .github/workflows/pr-checklist.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index 7557cf9ed..ead96a138 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -19,21 +19,21 @@ jobs: # Get the changed files in the pull request CHANGED_FILES=$(gh pr diff ${{ github.event.pull_request.number }} --name-only) if echo "$CHANGED_FILES" | grep -qE '^pages/'; then - echo "TRUE" >> $GITHUB_ENV + echo "is_pages_changed=TRUE" >> $GITHUB_OUTPUT else - echo "FALSE" >> $GITHUB_ENV + echo "is_pages_changed=FALSE" >> $GITHUB_OUTPUT fi - name: Parse Checklist id: parse_checklist - if: ${{ env.is_pages_changed == 'TRUE' }} + if: ${{ steps.check_files.outputs.is_pages_changed == 'TRUE' }} run: | # Read the checklist file from the repository CHECKLIST=$(sed -E 's/^[0-9]+\.\s+-?/- [ ] /' pages/contribute/editors_checklist.md) - echo "CHECKLIST=$CHECKLIST" >> $GITHUB_ENV + echo "CHECKLIST=$CHECKLIST" >> $GITHUB_OUTPUT - name: Add Review Comment - if: env.CHECKLIST != '' + if: ${{ steps.parse_checklist.outputs.CHECKLIST != '' }} uses: actions/github-script@v6 with: script: | @@ -43,9 +43,9 @@ jobs: const owner = context.payload.pull_request.head.repo.owner.login; // Get code owner const repo = context.payload.pull_request.head.repo.name; - await github.pulls.createReviewComment({ + await github.rest.pulls.createReviewComment({ owner: owner, repo: repo, pull_number: prNumber, body: template, - }); + }) From 755de96dcdbffbd336c33494ce25786ce0045f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Korbinian=20B=C3=B6sl?= Date: Tue, 25 Nov 2025 12:19:04 +0100 Subject: [PATCH 8/8] Update pr-checklist.yml --- .github/workflows/pr-checklist.yml | 42 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml index ead96a138..f99c27d7f 100644 --- a/.github/workflows/pr-checklist.yml +++ b/.github/workflows/pr-checklist.yml @@ -1,8 +1,8 @@ -name: Add editorial checklist upon review +name: Add editorial checklist upon PR on: - pull_request_review: - types: [submitted] + pull_request: + branches: [ master, main ] jobs: add_template: @@ -28,24 +28,28 @@ jobs: id: parse_checklist if: ${{ steps.check_files.outputs.is_pages_changed == 'TRUE' }} run: | - # Read the checklist file from the repository - CHECKLIST=$(sed -E 's/^[0-9]+\.\s+-?/- [ ] /' pages/contribute/editors_checklist.md) - echo "CHECKLIST=$CHECKLIST" >> $GITHUB_OUTPUT + # Read the checklist file, strip front-matter, convert numbered items to unchecked markdown list, base64-encode + sed -E '/^---$/,/^---$/d; s/^[0-9]+\.\s*-?\s*/- [ ] /' pages/contribute/editors_checklist.md | base64 -w0 > /tmp/checklist.b64 + echo "checklist_b64=$(cat /tmp/checklist.b64)" >> $GITHUB_OUTPUT - name: Add Review Comment - if: ${{ steps.parse_checklist.outputs.CHECKLIST != '' }} + if: ${{ steps.parse_checklist.outputs.checklist_b64 != '' }} uses: actions/github-script@v6 + env: + CHECKLIST_B64: ${{ steps.parse_checklist.outputs.checklist_b64 }} with: + github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const checklist = process.env.CHECKLIST; - const template = `### Review Checklist\n\n${checklist}\n\nPlease refer to the complete [editor's checklist](https://github.com/elixir-europe/rdmkit/edit/master/pages/contribute/editors_checklist.md) for details.`; - const prNumber = context.payload.pull_request.number; - const owner = context.payload.pull_request.head.repo.owner.login; // Get code owner - const repo = context.payload.pull_request.head.repo.name; - - await github.rest.pulls.createReviewComment({ - owner: owner, - repo: repo, - pull_number: prNumber, - body: template, - }) + const checklist = Buffer.from(process.env.CHECKLIST_B64 || '', 'base64').toString('utf8'); + const template = `### Editors checklist\n\n${checklist}\n\nPlease refer to the complete [editor's checklist](https://rdmkit.elixir-europe.org/editors_checklist) for details.`; + try { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: template + }); + } catch (error) { + console.error('Error creating comment:', error); + throw error; + }