From f599d149e86ea32b92af4035acc8a00622a28fde Mon Sep 17 00:00:00 2001 From: versnic <37933264+versnic@users.noreply.github.com> Date: Mon, 9 Nov 2026 00:49:19 +0100 Subject: [PATCH] ci: check the ai use section with modulane/ai-disclosure The released action replaces the inline script, so a fix to the check reaches this repository through a Dependabot pull request. --- .github/workflows/ai-disclosure.yml | 53 ++--------------------------- 1 file changed, 3 insertions(+), 50 deletions(-) diff --git a/.github/workflows/ai-disclosure.yml b/.github/workflows/ai-disclosure.yml index 8bdec69..0b41d18 100644 --- a/.github/workflows/ai-disclosure.yml +++ b/.github/workflows/ai-disclosure.yml @@ -6,8 +6,8 @@ name: AI disclosure # did written under it. This check fails until exactly one box is ticked, and # the main ruleset requires it. Editing the description runs it again. # -# It reads the description from the event, through an environment variable, -# and needs no token and no checkout. Dependabot pull requests are exempt. +# modulane/ai-disclosure reads the description from the event and needs no +# token and no checkout. Dependabot pull requests are exempt. on: pull_request: types: [opened, edited, reopened, synchronize] @@ -27,51 +27,4 @@ jobs: steps: - name: Check the AI use section - env: - BODY: ${{ github.event.pull_request.body }} - AUTHOR: ${{ github.event.pull_request.user.login }} - run: | - if [ "$AUTHOR" = 'dependabot[bot]' ]; then - echo 'Dependabot pull request: no disclosure needed.' - exit 0 - fi - - node - <<'JS' - const body = (process.env.BODY ?? '').replace(//g, '') - const fail = (message) => { - console.log(`::error::${message}`) - process.exit(1) - } - - const section = body.match(/^##[ \t]+AI use[ \t]*$([\s\S]*?)(?=^##[ \t]|(?![\s\S]))/im) - if (!section) { - fail('The description has no "## AI use" section. Copy it from the pull request template and tick one box.') - } - - const box = /^[ \t]*[-*][ \t]+\[([ xX])\][ \t]+(.*)$/ - const lines = section[1].split(/\r?\n/) - const ticked = lines.map((line) => line.match(box)).filter((m) => m && m[1] !== ' ') - const none = ticked.some((m) => /^no ai tool/i.test(m[2])) - const used = ticked.some((m) => /^ai tools were used/i.test(m[2])) - - if (none === used) { - fail('In the "AI use" section, tick exactly one box: "No AI tool was used" or "AI tools were used".') - } - - if (used) { - // The description can follow the box on its line, or the lines under it. - const details = lines - .map((line) => { - const m = line.match(box) - return m ? (/^ai tools were used/i.test(m[2]) ? m[2].replace(/^[^:]*:?/, '') : '') : line - }) - .join(' ') - .replace(/\s+/g, ' ') - .trim() - if (details.length < 20) { - fail('"AI tools were used" is ticked: under it, name each tool and what it did.') - } - } - - console.log(none ? 'Disclosed: no AI tool was used.' : 'Disclosed: AI tools were used, and how.') - JS + uses: modulane/ai-disclosure@5d2b11a0b28a8103f1b8d9ac31c7c7d79688b218 # v1.0.0