Skip to content

Instantly share code, notes, and snippets.

@Sciss
Created June 25, 2020 07:15
Show Gist options
  • Save Sciss/ff9a2a30faf111dd9c0971b554d9b72c to your computer and use it in GitHub Desktop.
Save Sciss/ff9a2a30faf111dd9c0971b554d9b72c to your computer and use it in GitHub Desktop.
#!/bin/bash
# run this with personal-access-token (repo scope) as argument
# cf. https://stackoverflow.com/questions/53452910/how-to-remove-a-github-environment
env=github-pages
token=$1
repo=Mellite
user=Sciss
if [ $# -eq 0 ]
then
echo "No access token supplied"
exit 1
fi
for id in $(curl -u $user:$token https://api.github.com/repos/$user/$repo/deployments\?environment\=$env | jq ".[].id"); do
curl -X POST -u $user:$token -d '{"state":"inactive"}' -H 'accept: application/vnd.github.ant-man-preview+json' https://api.github.com/repos/$user/$repo/deployments/$id/statuses
curl -X DELETE -u $user:$token https://api.github.com/repos/$user/$repo/deployments/$id
done
@Sciss
Copy link
Author

Sciss commented Jun 25, 2020

This requires that jq is installed: sudo apt install jq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment