Files
awesome-for-beginners/.github/workflows/invalid.yml
T
Sammy Hori a3e64b1423 Change invalidation workflow to active only when README.md edited
Beforehand it would active when any filepath not explicitly stated was edited, meaning if someone added a file it would incorrectly be given the "README.md file should not be manually edited" error.
2026-10-01 13:57:21 +01:00

37 lines
1.2 KiB
YAML

name: Check README.md edit - invalid PR check
on:
pull_request_target:
branches:
- main
paths:
- 'README.md'
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'This PR is not valid (README.md file should not be manually edited). Please read [contributing guidelines](https://github.com/MunGell/awesome-for-beginners/blob/main/CONTRIBUTING.md).'
});
if (context.payload.pull_request.labels.indexOf('invalid: README.md edited') === -1) {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['invalid: README.md edited']
});
}
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
state: 'closed'
});