-
Notifications
You must be signed in to change notification settings - Fork 1
Remove old student repositories #1
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Remove the old student repositories via api
- requires:
- a TOKEN with the permissions:
delete_repo,read:org curl(installed on ubuntu)jq(installed on ubuntu)
- a TOKEN with the permissions:
- store the following code as script
- run
bash delete_repos.sh TOKEN
delete_repos.sh
#!/bin/bash
GITHUB_TOKEN=$1
ORGANISATION="KonstanzPythonSchool"
assigment_nr=*
case $GITHUB_TOKEN in
""|-h|-help|--help)
echo "bash $0 <token>"
echo "token need to have the permissions : delete_repo, read:org"
exit 1
;;
*)
;;
esac
JSON=$(curl -s -H "Authorization: bearer $GITHUB_TOKEN" https://api.github.com/graphql -d @- << EOF
{
"query" : "query {
organization(login: \"${ORGANISATION}\") {
repositories(first: 100, privacy: PRIVATE) {
nodes { name }
}
}
}"
}
EOF
)
REPOS=$(echo $JSON | jq -r ".data.organization.repositories.nodes[].name")
for repo in $REPOS; do
if [[ $repo == assignment-${assigment_nr} ]]; then
echo "delete: $repo"
curl -H "Authorization: token $GITHUB_TOKEN" -XDELETE https://api.github.com/repos/${ORGANISATION}/$repo
fi
doneReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request