Skip to content

graph.js.org

graph.js.org #8734

Workflow file for this run

name: Validate
on:
push:
branches:
- master
pull_request:
branches:
- master
types:
- opened
- reopened
- edited
- synchronize
permissions: {}
jobs:
validate-cnames:
name: cnames_active.js
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: js-org/js.org-cleanup
path: cleanup
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version-file: cleanup/.nvmrc
cache: npm
cache-dependency-path: cleanup/package-lock.json
- name: Install dependencies
run: npm ci
working-directory: cleanup
- name: Validate cnames_active.js
run: node index.js --validate ../cnames_active.js
working-directory: cleanup
validate-description:
# Only validate descriptions for PRs, except when the PR is from Dependabot
if: github.event_name == 'pull_request' && github.event.pull_request.user.login != 'dependabot[bot]'
name: PR description
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Validate PR description
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const body = context.payload.pull_request.body || "";
const failures = [];
// 1. Check both checkboxes
const reasonableContent = /^[ \t]*-[ \t]+\[x\].*?There is reasonable content on the page/im.test(body);
if (!reasonableContent) failures.push("Reasonable content checkbox is not checked.");
const termsAndConditions = /^[ \t]*-[ \t]+\[x\].*?I have read and accepted the \[Terms and Conditions\]/im.test(body);
if (!termsAndConditions) failures.push("Terms and conditions checkbox is not checked.");
// 2. URL must be on the exact "The site content can be seen at ..." line
// https://regex101.com/r/N36fsT
const url = /^[ \t]*-[ \t]*The site content can be seen at[ \t]+(?:<)?(?:\[.*?\]\()?https?:\/\/[^\s>()]+(?:\))?(?:>)?/im.exec(body);
if (!url) failures.push("Content URL is missing or not in the correct format.");
// 3. Explanation must follow the blockquote marker
const explanation = />\s*The site content is(?:\s*|\s*\n)(.+)(?:\s*|\s*\n)and is relevant to JavaScript developers specifically because(?:\s*|\s*\n)(.+)/i.exec(body);
if (!explanation || explanation[1].trim().length <= 10 || explanation[2].trim().length <= 10) failures.push("Content explanation is missing or too short.");
if (failures.length) {
core.setFailed(["❌ PR description format is invalid.", ...failures.map(f => `- ${f}`)].join("\n"));
} else {
console.log("✅ PR description format is valid.");
}