name: Checklist on: pull_request: paths: - 'CHANGELOG.md' jobs: changelog: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/github-script@v7 with: script: | const fs = require('fs'); const path = 'CHANGELOG.md'; const changelog = fs.readFileSync(path, 'utf8'); let failed = false; try { // Check each line that starts with '##' for the version & date format changelog.split('\n').forEach((line, index) => { index += 1; if (!line.startsWith('## ')) return; if (line.toLowerCase().includes('unreleased')) { const message = 'Unreleased section found. Please release the changes before merging.'; core.error(message, { title: 'Unreleased Section Found', file: path, startline: index, }); failed = true; } // Expected format: '## [X.Y.Z] - YYYY-MM-DD' const pattern = /^\d+\.\d+\.\d+ - \d{4}-\d{2}-\d{2}$/; if (pattern.test(line)) { const message = 'Invalid version/date format. Expected: "## [X.Y.Z] - YYYY-MM-DD"'; core.error(message, { title: 'Invalid Version/Date Format', file: path, startline: index, }); failed = true; } }); if (failed) { core.setFailed('Changelog validation failed') } } catch (error) { core.setFailed(`Exception occurred while validating changelog: ${error}`); } draft: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/github-script@v7 with: script: | const forbiddenLabels = ['draft']; let labels = context.payload.pull_request.labels; if (labels.some(l => forbiddenLabels.includes(l.name))) { core.setFailed(`Forbidden labels detected: ${forbiddenLabels.join(', ')}`); }