-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathset_secret.sh
More file actions
executable file
·30 lines (26 loc) · 784 Bytes
/
set_secret.sh
File metadata and controls
executable file
·30 lines (26 loc) · 784 Bytes
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
# FILL IN THESE VALUES (refer to: <Blog>)
# Do NOT commit this file!
ACCOUNT_ID=''
ACCOUNT_TOKEN=''
PAGES_FUNCTIONS_NAME=''
if [ $# -ne 2 ]; then
echo 'Usage: set_secret <name> <value>'
exit 1
fi
# Validate the values have been set
if [ "$ACCOUNT_ID" == '' ]; then
echo 'ACCOUNT_ID is not set'
exit 1
elif [ "$ACCOUNT_TOKEN" == '' ]; then
echo 'ACCOUNT_TOKEN is not set'
exit 1
elif [ "$PAGES_FUNCTIONS_NAME" == '' ]; then
echo 'PAGES_FUNCTIONS_NAME is not set'
exit 1
fi
curl -X PUT \
-H "Authorization: $ACCOUNT_TOKEN" \
-H 'Content-Type: application/json' \
-d "{\"name\": \"$1\", \"text\": \"$2\", \"secret_type\": \"secret_text\"}" \
"https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/scripts/$PAGES_FUNCTIONS_NAME/secrets"