Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
3,927 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
CLOUDFLARE_KV_BINDING_ID=$1 | ||
CLOUDFLARE_KV_KEY=$2 | ||
CLOUDFLARE_KV_VALUE=$3 | ||
|
||
function check_requirements() { | ||
if [[ -z "$(command -v node)" ]]; then | ||
echo "Please install 'node' program before running this script" | ||
exit 1 | ||
elif [[ -z "$CLOUDFLARE_ACCOUNT_ID" ]]; then | ||
echo "Please ensure environment variable 'CLOUDFLARE_ACCOUNT_ID' exists before running this script" | ||
exit 1 | ||
elif [[ -z "$CLOUDFLARE_API_TOKEN" ]]; then | ||
echo "Please ensure environment variable 'CLOUDFLARE_API_TOKEN' exists before running this script" | ||
exit 1 | ||
elif [[ -z "$CLOUDFLARE_KV_BINDING_ID" ]]; then | ||
echo "Arg 1 for script 'CLOUDFLARE_KV_BINDING_ID' was not given..." | ||
exit 1 | ||
elif [[ -z "$CLOUDFLARE_KV_KEY" ]]; then | ||
echo "Arg 2 for script 'CLOUDFLARE_KV_KEY' was not given..." | ||
exit 1 | ||
elif [[ -z "$CLOUDFLARE_KV_VALUE" ]]; then | ||
echo "Arg 3 for script 'CLOUDFLARE_KV_VALUE' was not given..." | ||
exit 1 | ||
fi | ||
} | ||
|
||
function main() { | ||
check_requirements | ||
|
||
if ! ./node_modules/.bin/wrangler kv:key get "$CLOUDFLARE_KV_KEY" --namespace-id="$CLOUDFLARE_KV_BINDING_ID" > /dev/null 2>&1; then | ||
echo "Adding Cloudflare KV key '$CLOUDFLARE_KV_KEY' and value '$CLOUDFLARE_KV_VALUE' to KV '$CLOUDFLARE_KV_NAME'..." | ||
./node_modules/.bin/wrangler kv:key put "$CLOUDFLARE_KV_KEY" "$CLOUDFLARE_KV_VALUE" --namespace-id="$CLOUDFLARE_KV_BINDING_ID" | ||
fi | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
|
Oops, something went wrong.