Skip to content

Instantly share code, notes, and snippets.

@0xdade
Last active September 29, 2020 05:01
Show Gist options
  • Save 0xdade/48171b0ade8c406f401bd25bce24344d to your computer and use it in GitHub Desktop.
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
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