Cron trigger script that initiates workflow execution via Render SDK.
Lightweight Python script that triggers the main_analysis_task workflow using the Render Workflows SDK. Can be run manually or via cron job.
| File | Purpose |
|---|---|
trigger.py |
Main trigger script using Render SDK |
requirements.txt |
Python dependencies |
# 1. Auth check — skipped when GITHUB_PAT is set; runs refresh_auth.py for OAuth
if GITHUB_PAT:
print("✓ Using GITHUB_PAT — skipping auth refresh")
else:
await refresh_github_auth()
# 2. Initialize Render client (uses RENDER_API_KEY from env)
client = Client()
# 3. Trigger workflow task
task_identifier = f"{workflow_slug}/main_analysis_task"
run = await client.workflows.run_task(
task_identifier=task_identifier,
input_data=[] # No arguments needed
)
# 4. Return run metadata
print(f"Task Run ID: {run.id}")
print(f"Status: {run.status}")# Required
RENDER_API_KEY=rnd_... # From dashboard.render.com/u/settings#api-keys
RENDER_WORKFLOW_SLUG=trender-wf # Your workflow slug
# GitHub auth — set ONE of the following:
GITHUB_PAT=ghp_... # Option 1: PAT (skips Step 1 entirely)
# -- OR --
GITHUB_CLIENT_ID=... # Option 2: OAuth App (all four required)
GITHUB_CLIENT_SECRET=...
GITHUB_TOKEN_ENCRYPTION_KEY=...
DATABASE_URL=postgresql://...
# Optional (for local dev)
RENDER_USE_LOCAL_DEV=true
RENDER_LOCAL_DEV_URL=http://localhost:8120Note: The script loads .env from the parent directory automatically.
cd trigger
pip install -r requirements.txt
# Set environment variables
export RENDER_API_KEY=your_api_key
export RENDER_WORKFLOW_SLUG=trender-wf
# Run trigger
python trigger.pyTo trigger the deployed (production) workflow, ensure your .env file has:
RENDER_USE_LOCAL_DEV=false
# RENDER_LOCAL_DEV_URL=http://localhost:8120 # Comment this out!To trigger your local development workflow, set:
RENDER_USE_LOCAL_DEV=true
RENDER_LOCAL_DEV_URL=http://localhost:8120Note: RENDER_LOCAL_DEV_URL takes precedence over RENDER_USE_LOCAL_DEV, so it must be commented out to reach production, even if RENDER_USE_LOCAL_DEV=false.
Expected output:
Triggering task: trender-wf/main_analysis_task
✓ Workflow triggered successfully at 2026-02-02 12:00:00
Task Run ID: run_abc123xyz
Initial Status: running
# Create .env in project root
echo "RENDER_API_KEY=rnd_..." >> ../.env
echo "RENDER_WORKFLOW_SLUG=trender-wf" >> ../.env
# Run (automatically loads .env)
python trigger.pyThe trigger script is designed to run as a Render cron job (see render.yaml):
- type: cron
name: trender-cron
runtime: python
schedule: "0 14 * * *" # Daily at 14:00 UTC (6 AM PST)
buildCommand: cd trigger && pip install -r requirements.txt
startCommand: cd trigger && python trigger.py
envVars:
- key: RENDER_WORKFLOW_SLUG
sync: false
- key: RENDER_API_KEY
sync: falseSchedule format: Standard cron syntax
0 14 * * *= Daily at 14:00 UTC*/15 * * * *= Every 15 minutes0 */2 * * *= Every 2 hours
When testing workflows locally, set RENDER_USE_LOCAL_DEV:
# .env file
RENDER_USE_LOCAL_DEV=true
RENDER_LOCAL_DEV_URL=http://localhost:8120
RENDER_WORKFLOW_SLUG=trender-wfWorkflow:
- Start local task server:
cd workflows && python workflow.py - Run trigger:
cd trigger && python trigger.py
Or use orchestrator: python bin/local_dev.py
The script returns a dictionary with workflow run metadata:
{
'run_id': 'run_abc123xyz',
'status': 'running', # or 'completed', 'failed'
'task_identifier': 'trender-wf/main_analysis_task'
}Missing API key:
Error: RENDER_API_KEY environment variable is required
Invalid workflow slug:
✗ Exception during workflow trigger: Workflow not found
Network errors:
✗ Exception during workflow trigger: Connection timeout
After triggering, monitor via:
- Go to Workflows section
- Select
trender-wf - View recent runs and logs
psql $DATABASE_URL -c "
SELECT
run_id,
status,
started_at,
completed_at,
repos_processed,
execution_time_seconds
FROM fact_workflow_runs
ORDER BY started_at DESC
LIMIT 1;
"curl https://trender-dashboard.onrender.com/api/workflow-status| Issue | Solution |
|---|---|
| "RENDER_API_KEY not set" | Export key or add to .env file |
| "Connection refused" to localhost | Comment out RENDER_LOCAL_DEV_URL in .env to reach production |
| "Workflow not found" | Verify RENDER_WORKFLOW_SLUG matches dashboard |
| Script hangs | Check network connectivity to Render API |
| "Task not found" | Ensure workflow is deployed with main_analysis_task |
| "All connection attempts failed" | Check if RENDER_LOCAL_DEV_URL is set (should be commented out for production) |
| Auth refresh fails but you have a PAT | Set GITHUB_PAT in env — Step 1 will be skipped automatically |
See requirements.txt:
render-sdk>=0.1.0 # Render Workflows SDK
python-dotenv # Environment variable loadingInstall:
pip install -r requirements.txtImport and use in other Python scripts:
from trigger import trigger_workflow
import asyncio
# Trigger workflow
result = asyncio.run(trigger_workflow())
if result:
print(f"Workflow started: {result['run_id']}")
else:
print("Failed to trigger workflow")- Test locally:
python trigger.py - Verify workflow runs successfully
- Check logs for any errors
- Deploy: Push to GitHub (auto-deploy)