Update README to specify current version #2
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: Auto-merge README/docs PRs | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
paths: | |
- 'README.md' | |
- 'docs/**' | |
- 'CHANGELOG.md' | |
- '*.md' | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
automerge: | |
if: ${{ !github.event.pull_request.draft }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Enforce allowlist and path-only change | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const allow = ['gmondello']; // Add trusted users here | |
const pr = context.payload.pull_request; | |
// Check if author is in allowlist | |
if (!allow.includes(pr.user.login)) { | |
core.setFailed(`Author '${pr.user.login}' not in allowlist`); | |
return; | |
} | |
// Get the files changed in this PR | |
const { data: files } = await github.rest.pulls.listFiles({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pr.number, | |
}); | |
// Define allowed paths (documentation only) | |
const allowedPatterns = [ | |
/^README\.md$/, | |
/^CHANGELOG\.md$/, | |
/^docs\//, | |
/^.*\.md$/, // Any markdown file | |
]; | |
// Check if all changed files match allowed patterns | |
const invalidFiles = files.filter(file => { | |
return !allowedPatterns.some(pattern => pattern.test(file.filename)); | |
}); | |
if (invalidFiles.length > 0) { | |
core.setFailed(`PR contains non-documentation files: ${invalidFiles.map(f => f.filename).join(', ')}`); | |
return; | |
} | |
core.info(`✅ PR approved for auto-merge: ${files.length} documentation files changed`); | |
core.info(`Files: ${files.map(f => f.filename).join(', ')}`); | |
- name: Enable auto-merge | |
uses: peter-evans/enable-pull-request-automerge@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
merge-method: squash | |
- name: Add auto-merge label | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.pull_request.number, | |
labels: ['auto-merge', 'documentation'] | |
}); |