Created
March 31, 2026 20:35
-
-
Save kyeotic/a9a3ed42bb7be6b66d58cf70053da977 to your computer and use it in GitHub Desktop.
Get the Cloudflare Pages Subdomain
This file contains hidden or 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
| #!/bin/bash | |
| # Reads account_id and project_name from stdin JSON, returns subdomain as JSON | |
| set -euo pipefail | |
| INPUT=$(cat) | |
| ACCOUNT_ID=$(echo "$INPUT" | jq -r '.account_id') | |
| PROJECT_NAME=$(echo "$INPUT" | jq -r '.project_name') | |
| SUBDOMAIN=$(curl -sf \ | |
| -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ | |
| "https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/pages/projects/${PROJECT_NAME}" \ | |
| | jq -r '.result.subdomain') | |
| jq -n --arg subdomain "$SUBDOMAIN" '{"subdomain": $subdomain}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment