Skip to content

Instantly share code, notes, and snippets.

@0xdade
Last active Sep 29, 2020
Embed
What would you like to do?
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