Skip to content

Sir.css

Sir.css #73

Workflow file for this run

name: Auto Close PRs
on:
pull_request_target:
types: [opened, reopened]
jobs:
check_pr:
name: Check PR
runs-on: ubuntu-latest
steps:
- name: Check if employee
id: check_employee
uses: actions/github-script@v6
with:
github-token: ${{ secrets.READ_GITHUB_ORG_MEMBERS_TOKEN }}
result-encoding: string
script: |
try {
const response = await github.rest.orgs.checkMembershipForUser({
org: `github`,
username: context.payload.pull_request.user.login
});
if (response.status === 204) {
return true;
} else {
return false;
}
} catch (error) {
console.log(error);
return 'false';
}
- name: Close PR
id: close_pr
if: ${{ steps.check_employee.outputs.result == 'false' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const body = `This pull request is being automatically closed because we do not accept external contributions to this repository.`;
await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: body
});
await github.rest.pulls.update({
...context.repo,
pull_number: context.payload.pull_request.number,
state: 'closed'
});