-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Delete.sh
30 lines (23 loc) · 1.24 KB
/
Delete.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# shellcheck source=/dev/null
source .env
# Fill entries
mapfile -t Projects < <(curl -s --header "content-type: application/json;charset=UTF-8" --header "X-Auth-Email: ${Email:?}" --header "X-Auth-Key: ${Key:?}" "https://api.cloudflare.com/client/v4/accounts/${ID:?}/pages/projects" | \jq -r '.result[].name')
# Clean entries
for i in "${!Projects[@]}"; do
Projects[i]=$(echo "${Projects[i]}" | sed ':a;N;$!ba;s/\n//g')
done
# Fill entries
for Project in "${Projects[@]}"; do
readarray -t Deployments < <(curl -s --header "content-type: application/json;charset=UTF-8" --header "X-Auth-Email: ${Email}" --header "X-Auth-Key: ${Key}" "https://api.cloudflare.com/client/v4/accounts/${ID}/pages/projects/${Project}/deployments" | jq -r .result[].id)
# Clean entries
for i in "${!Deployments[@]}"; do
Deployments[i]=$(echo "${Deployments[i]}" | sed ':a;N;$!ba;s/\n//g')
done
# Delete deployments
for Deployment in "${Deployments[@]}"; do
echo -e "$Project"
echo -e "$Deployment"
curl -s --header "content-type: application/json;charset=UTF-8" --header "X-Auth-Email: ${Email}" --header "X-Auth-Key: ${Key}" "https://api.cloudflare.com/client/v4/accounts/${ID}/pages/projects/${Project}/deployments/${Deployment}" | jq -r .success
done
done