Last active
September 29, 2020 05:01
-
-
Save 0xdade/48171b0ade8c406f401bd25bce24344d to your computer and use it in GitHub Desktop.
Github action to automatically limit the repo to collaborators every day. REPO_MANAGER is a personal access token in the repository secrets. Gross, but github doesn't give us individual repo admin tokens because it's 2020 and principle of yoloscope
This file contains hidden or 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: Automatically limit | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
limiter: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Remove existing limit | |
run: | | |
curl --request DELETE \ | |
--url https://api.github.com/repos/${{ github.repository }}/interaction-limits \ | |
--header 'authorization: Bearer ${{ secrets.REPO_MANAGER }}' \ | |
--header 'content-type: application/json' \ | |
--header 'Accept: application/vnd.github.sombra-preview' \ | |
- name: Set new limit | |
run: | | |
curl --request PUT \ | |
--url https://api.github.com/repos/${{ github.repository }}/interaction-limits \ | |
--header 'authorization: Bearer ${{ secrets.REPO_MANAGER }}' \ | |
--header 'content-type: application/json' \ | |
--header 'Accept: application/vnd.github.sombra-preview' \ | |
--data '{ | |
"limit": "collaborators_only" | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment