Create ban_README_edit

This commit is contained in:
yzqzss 2023-12-30 16:28:26 +08:00 committed by GitHub
parent 5ec7212008
commit c5ce8d5fb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

22
.github/workflows/ban_README_edit vendored Normal file
View File

@ -0,0 +1,22 @@
name: Close PR on README.md change
on:
pull_request:
types: [edited]
jobs:
close_pr:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Check for README.md changes
run: |
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -q "^README.md$"; then
echo "README.md has been modified. Closing the PR."
curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -d '{"state":"closed"}' "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}"
else
echo "No changes to README.md. Nothing to do."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}