← ClaudeAtlas

gcp-dataform-rest-api-deploylisted

Deploy .sqlx files to Google Cloud Dataform repositories via REST API without the Dataform CLI. Use when: (1) deploying Dataform SQL from CI/CD or scripts, (2) programmatically updating Dataform workspaces, (3) triggering Dataform invocations from Cloud Workflows or automation, (4) adding NEW .sqlx files to a Dataform repo that also hosts other production release configs (v1.1.0: requires pre-merge workspace compile + post-merge cross-check gating to avoid breaking sibling release configs), (5) hitting "Only a commitish value of main is allowed" error when trying to compile a dev branch or non-main gitCommitish, (6) needing to discover exact target names with `_loader` suffix for workflowInvocations includedTargets, (7) renaming a .sqlx file whose `name:` (target name) is unchanged — both old and new produce the same target so they can't coexist (v1.2.0: atomic write+remove in one workspace commit + Gate-3 post-push compile against EVERY release config, with rollback recipe). Covers the full lifecycle: writeF
wan-huiyan/gcp-dataform-rest-api-deploy · ★ 0 · API & Backend · score 74
Install: claude install-skill wan-huiyan/gcp-dataform-rest-api-deploy
# GCP Dataform REST API Deploy ## Problem Deploying .sqlx files to Dataform programmatically (from scripts, CI/CD, or automation) without the Dataform CLI. The REST API has non-obvious endpoint patterns and a specific workflow order. ## Context / Trigger Conditions - Need to deploy Dataform SQL files from a script or automation pipeline - Want to trigger specific Dataform targets after deployment - Cloud Workflows needs to invoke Dataform compilations and invocations - Error: 404 on Dataform API calls (URL formatting issue with colon actions) - Error: "Unknown name" in commit payload (wrong field names) ## Solution ### Full Deployment Lifecycle ```bash ACCESS_TOKEN=$(gcloud auth print-access-token) BASE="https://dataform.googleapis.com/v1beta1" PROJECT_ID="my-project" REGION="europe-north1" # Dataform region (often different from Cloud Run region) REPO="my-repo" WORKSPACE="my-workspace" WS_PATH="projects/$PROJECT_ID/locations/$REGION/repositories/$REPO/workspaces/$WORKSPACE" # Step 1: Write file to workspace (content must be base64-encoded) ENCODED=$(base64 -i path/to/file.sqlx) curl -s -X POST \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"path\": \"definitions/my_model.sqlx\", \"contents\": \"$ENCODED\"}" \ "${BASE}/${WS_PATH}:writeFile" # Step 2: Commit changes in the workspace curl -s -X POST \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "author": {"name": "Auth