Skip to content

Instantly share code, notes, and snippets.

@michilu
Created July 15, 2018 02:24
Show Gist options
  • Save michilu/ac1921c28195f6856cb1e27b980dc91a to your computer and use it in GitHub Desktop.
Save michilu/ac1921c28195f6856cb1e27b980dc91a to your computer and use it in GitHub Desktop.
delete all sites that name end with random strings on the netlify
#!/bin/bash
set -x
curl -X GET "https://api.netlify.com/api/v1/sites" -H "accept: application/json" -H "authorization: Bearer $NETLIFY_TOKEN" -f \
| jq '.[]|select(.name|match("^.+-[0-9a-f]{6}$"))|.id' -r \
| xargs -t -L1 bash -c 'curl -X DELETE "https://api.netlify.com/api/v1/sites/$0" -H "authorization: Bearer $NETLIFY_TOKEN"' \
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment