gcp-dataform-rest-api-deploylisted
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