diff --git a/.github/workflows/auto-close-pr.yml b/.github/workflows/auto-close-pr.yml new file mode 100644 index 0000000..7533c57 --- /dev/null +++ b/.github/workflows/auto-close-pr.yml @@ -0,0 +1,55 @@ +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' + }); \ No newline at end of file diff --git a/profile/README.md b/profile/README.md index 7c54222..5397970 100644 --- a/profile/README.md +++ b/profile/README.md @@ -8,7 +8,6 @@ GitHub Community is built to support all GitHub users on their educational journ * [Join Global Campus](https://education.github.com/benefits?type=student) * [GitHub Community Guidelines](https://docs.github.com/en/site-policy/github-terms/github-community-guidelines) * [Student Developer Pack Application & FAQs](https://github.com/orgs/community/discussions/17814) -* [GitHub Community Discourse ➡️ Discussions Categories](https://github.com/orgs/github-community/discussions/21279) ### Documentation @@ -18,6 +17,20 @@ GitHub Community is built to support all GitHub users on their educational journ ### Other Ways to Participate * [GitHub Stars Program](https://stars.github.com/program/) -* [GitHub Events](https://github.com/events) +* [GitHub Campus Experts Program](https://education.github.com/experts) +* [GitHub Events](https://www.meetup.com/pro/github-virtual-meetup/) * [GitHub Blog](https://github.blog/) +* [The ReadME Project & Podcast](https://github.com/readme) * [GitHub YouTube Channel](https://www.youtube.com/github) + +#### Quick note on 3rd party integrations +> _Due to an overwhelming number of suspicious requests from community members for 3rd party apps and integrations to this org, we've turned off "Allow integration requests from outside collaborators"._ + +#### Quick note on temporary interaction limits +In an effort to reduce spammy behavior, we are instituting temporary interaction limits to bar accounts less than 24hrs-old from participating in the `github.com/community` Discussions space. +Accounts that are at least 24hrs old will be able to post and interact as normal. + +If your account is less than 24hrs old and you have a question, please try using the Discussions search bar above to see if your question has already been asked or simply wait a day. We apologize if this causes any inconvenience. + +If you'd like to learn more about implementing temporary interaction limits in your own orgs and repos, please read up on the official documentation [here](https://docs.github.com/en/communities/moderating-comments-and-conversations/limiting-interactions-in-your-organization). + diff --git a/workflow-templates/auto-close-pr.properties.json b/workflow-templates/auto-close-pr.properties.json new file mode 100644 index 0000000..8b9e20d --- /dev/null +++ b/workflow-templates/auto-close-pr.properties.json @@ -0,0 +1,4 @@ +{ + "name": "Auto close PRs", + "description": "Automatically close pull requests from non-staff." +} \ No newline at end of file diff --git a/workflow-templates/auto-close-pr.yml b/workflow-templates/auto-close-pr.yml new file mode 100644 index 0000000..7533c57 --- /dev/null +++ b/workflow-templates/auto-close-pr.yml @@ -0,0 +1,55 @@ +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' + }); \ No newline at end of file