mirror of
https://github.com/deployflare/test.git
synced 2026-01-13 16:18:02 +00:00
Update bind-everything.yml
This commit is contained in:
8
.github/workflows/bind-everything.yml
vendored
8
.github/workflows/bind-everything.yml
vendored
@@ -24,16 +24,17 @@ jobs:
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
run: |
|
||||
export CLOUDFLARE_ACCOUNT_ID=$(curl -sX GET "https://api.cloudflare.com/client/v4/accounts" -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" -H "Content-Type:application/json" | jq -r '.result[0].id')
|
||||
AID=$(curl -sX GET "https://api.cloudflare.com/client/v4/accounts" -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" -H "Content-Type:application/json" | jq -r '.result[0].id')
|
||||
if [ -z "$AID" ] || [ "$AID" == "null" ]; then echo "::error::Failed to retrieve Cloudflare Account ID." >&2; exit 1; fi
|
||||
|
||||
wrangler d1 list --json | jq -c '.[]' | while read -r db; do
|
||||
wrangler d1 list --json --account-id $AID | jq -c '.[]' | while read -r db; do
|
||||
id=$(jq -r .uuid <<< "$db"); name=$(jq -r .name <<< "$db")
|
||||
if ! grep -q "$id" wrangler.toml; then
|
||||
printf '\n[[d1_databases]]\nbinding = "%s"\ndatabase_name = "%s"\ndatabase_id = "%s"\n' "$(echo "$name"|tr '[:lower:]-' '[:upper:]_')" "$name" "$id" >> wrangler.toml
|
||||
fi
|
||||
done
|
||||
|
||||
wrangler kv:namespace list --json | jq -c '.[]' | while read -r kv; do
|
||||
wrangler kv:namespace list --json --account-id $AID | jq -c '.[]' | while read -r kv; do
|
||||
id=$(jq -r .id <<< "$kv"); title=$(jq -r .title <<< "$kv")
|
||||
if ! grep -q "$id" wrangler.toml; then
|
||||
printf '\n[[kv_namespaces]]\nbinding = "%s"\nid = "%s"\n' "$(echo "$title"|tr '[:lower:]-' '[:upper:]_')" "$id" >> wrangler.toml
|
||||
@@ -45,4 +46,3 @@ jobs:
|
||||
with:
|
||||
commit_message: "chore: Sync Cloudflare D1 & KV bindings"
|
||||
file_pattern: wrangler.toml
|
||||
|
||||
|
||||
Reference in New Issue
Block a user