Remove unused css files #433
This file contains 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: Check for non-GitHub Bot PRs | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
checks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/github-script@v7 | |
id: comment | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: return context.payload.issue.pull_request && context.payload.comment.body === '/check' | |
- uses: actions/checkout@v4 | |
if: steps.comment.outputs.result == 'true' | |
- name: Checkout Git Branch | |
if: steps.comment.outputs.result == 'true' | |
run: | | |
git fetch origin +refs/pull/${{ github.event.issue.number }}/merge | |
git checkout FETCH_HEAD | |
- name: Comment for non-GitHub Bot PRs | |
id: non-bot-check | |
if: steps.comment.outputs.result == 'true' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const { data: { merge_commit_sha, user: { login }} } = await github.rest.pulls.get({ | |
pull_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo | |
}); | |
console.log(`PR created by ${login}`); | |
if (login !== 'github-actions[bot]') { | |
const { data: { files }} = await github.rest.repos.getCommit({ | |
ref: merge_commit_sha, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}); | |
const protectedFiles = files.filter(({ filename }) => /^spec\//.test(filename)) | |
if (protectedFiles && protectedFiles.length) { | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Thank you for contribution!\nSeems like you trying to change specification not in a right place :thinking:\nThis repository contains code for website [semver.org](https://semver.org) with spec translations. If you are looking for direct changes to SemVer, please use [semver/semver](https://github.com/semver/semver) repository.\n\nPlease close this PR and create a new one to the right repository. If you have any questions, feel free to ping someone from @semver/maintainers' | |
}); | |
const comments = protectedFiles.map(({ filename }) => ({ | |
"path": filename, | |
"position": 1, | |
"body": "This file shouldn't be changed in this repo" | |
})) | |
await github.rest.pulls.createReview({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number, | |
event: 'REQUEST_CHANGES', | |
comments | |
}) | |
} else { | |
await github.rest.pulls.createReview({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number, | |
event: 'APPROVE' | |
}) | |
} | |
} |