doc/starlight: Update and migrate to new rust md parser #368
Workflow file for this run
This file contains hidden or 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
| name: Check AI disclosure in PRs | |
| on: | |
| pull_request_target: | |
| types: [opened, reopened, edited] | |
| permissions: | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| check-disclosure: | |
| name: Check AI disclosure section | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check if AI label is already present | |
| id: labels | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const hasAiLabel = context.payload.pull_request.labels.some( | |
| l => l.name.startsWith("AI: ") | |
| ); | |
| core.setOutput("has_ai_label", hasAiLabel); | |
| - name: Validate that PR body contains AI disclosure | |
| id: check | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| // Remove template hints. | |
| const body = (context.payload.pull_request.body || "") | |
| .replace(/\r/g, "") | |
| .replace(/<!--[\s\S]*?-->/g, ""); | |
| // Match first non-empty line that doesn't start with '#' | |
| const heading = `##+\\s+Declaration of AI-Tools \\/ LLMs usage:?`; | |
| const sectionRegex = new RegExp( | |
| `^${heading}\\s*(^\\s*[^#\\s].*$)`, | |
| "m" | |
| ); | |
| const match = body.match(sectionRegex); | |
| const missing = !match || match[1].trim().length === 0; | |
| core.setOutput("is_declaration_missing", String(missing)); | |
| - name: Remove AI label if declaration exists | |
| if: steps.check.outputs.is_declaration_missing == 'false' | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| try { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| name: "AI: Declaration Missing" | |
| }); | |
| } catch (error) { | |
| // Ignore if the label does not exist | |
| if (error.status !== 404) { | |
| throw error; | |
| } | |
| } | |
| - name: Comment on PR and add labels | |
| uses: actions/github-script@v9 | |
| if: >- | |
| steps.check.outputs.is_declaration_missing == 'true' && | |
| steps.labels.outputs.has_ai_label != 'true' | |
| with: | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| const user = context.payload.pull_request.user.login; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: `Hey @${user}, thank you for your contribution to RIOT! | |
| Please note that we require for all PRs to RIOT a declaration of AI-Tools / LLMs usage. It appears as if this section is missing in your PR. Please copy and fill in the section from .github/PULL_REQUEST_TEMPLATE.md. | |
| Thank you!` | |
| }); | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| labels: ["AI: Declaration Missing"] | |
| }); |