Convert to generated README infrastructure #2
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: Protect README | |
| on: | |
| pull_request: | |
| paths: | |
| - "README.md" | |
| jobs: | |
| check-readme: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Block direct README edits | |
| if: github.event.pull_request.user.type != 'Bot' | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const files = await github.paginate(github.rest.pulls.listFiles, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.payload.pull_request.number, | |
| per_page: 100, | |
| }); | |
| const hasSourceChanges = files.some(f => | |
| f.filename === 'awesome-list.yaml' || | |
| f.filename.startsWith('data/') || | |
| f.filename.startsWith('scripts/') || | |
| f.filename.startsWith('schema/') | |
| ); | |
| if (!hasSourceChanges) { | |
| core.setFailed( | |
| 'README.md must not be edited directly.\n\n' + | |
| 'This repository uses a data-first workflow and auto-generates README.md from YAML files.\n\n' + | |
| 'To suggest a new resource, open an issue instead:\n' + | |
| `https://github.com/${context.repo.owner}/${context.repo.repo}/issues/new/choose` | |
| ); | |
| } | |