@@ -32,22 +32,27 @@ jobs:
3232
3333 # Check required environment variables are set
3434 if [ -z "${RUNPOD_ASSISTANT_BASE_URL:-}" ]; then
35- echo "ERROR: RUNPOD_ASSISTANT_BASE_URL variable is not configured"
36- echo "Go to Settings → Secrets and variables → Actions → Variables"
35+ echo "::error::RUNPOD_ASSISTANT_BASE_URL is not configured"
36+ echo ""
37+ echo "To fix: Go to Settings > Secrets and variables > Actions > Variables"
38+ echo "Add a variable named RUNPOD_ASSISTANT_BASE_URL with the Mastra endpoint URL"
3739 exit 1
3840 fi
39- echo "✓ RUNPOD_ASSISTANT_BASE_URL is configured"
41+ echo "[OK] RUNPOD_ASSISTANT_BASE_URL is configured"
4042
4143 if [ -z "${RUNPOD_ASSISTANT_API_KEY:-}" ]; then
42- echo "ERROR: RUNPOD_ASSISTANT_API_KEY secret is not configured"
43- echo "Go to Settings → Secrets and variables → Actions → Secrets"
44+ echo "::error::RUNPOD_ASSISTANT_API_KEY is not configured"
45+ echo ""
46+ echo "To fix: Go to Settings > Secrets and variables > Actions > Secrets"
47+ echo "Add a secret named RUNPOD_ASSISTANT_API_KEY with the API key"
4448 exit 1
4549 fi
46- echo "✓ RUNPOD_ASSISTANT_API_KEY is configured"
50+ echo "[OK] RUNPOD_ASSISTANT_API_KEY is configured"
4751
4852 # Validate auth and workflow existence by creating a test run
4953 # Note: This creates an unstarted run as a side effect (harmless)
5054 RUN_ID="validation-$(uuidgen | tr '[:upper:]' '[:lower:]')"
55+ echo ""
5156 echo "Validating authentication and workflow existence..."
5257
5358 response=$(curl -s -w "\n%{http_code}" --max-time 30 -X POST \
@@ -59,24 +64,46 @@ jobs:
5964 http_code=$(echo "$response" | tail -n1)
6065 body=$(echo "$response" | sed '$d')
6166
62- if [ "$http_code" -eq 401 ] || [ "$http_code" -eq 403 ]; then
63- echo "ERROR: Authentication failed (HTTP $http_code)"
64- echo "Check that RUNPOD_ASSISTANT_API_KEY is correct"
65- exit 1
66- elif [ "$http_code" -eq 404 ]; then
67- echo "ERROR: Workflow 'ingestDocsWorkflow' not found (HTTP $http_code)"
68- echo "Verify the workflow is deployed to: ${RUNPOD_ASSISTANT_BASE_URL}"
69- exit 1
70- elif [ "$http_code" -ne 200 ]; then
71- echo "ERROR: Unexpected response (HTTP $http_code)"
72- echo "Response: $body"
73- exit 1
67+ if [ "$http_code" -eq 200 ]; then
68+ echo "[OK] Authentication successful"
69+ echo "[OK] Workflow 'ingestDocsWorkflow' exists"
70+ echo ""
71+ echo "Configuration validated - safe to merge"
72+ exit 0
7473 fi
7574
76- echo "✓ Authentication successful"
77- echo "✓ Workflow 'ingestDocsWorkflow' exists"
75+ # Provide specific error messages based on HTTP status
76+ echo ""
77+ echo "Response body: $body"
7878 echo ""
79- echo "Configuration validated - safe to merge"
79+
80+ case "$http_code" in
81+ 401|403)
82+ echo "::error::Authentication failed (HTTP $http_code)"
83+ echo ""
84+ echo "Cause: The API key was rejected by the server"
85+ echo "To fix: Verify RUNPOD_ASSISTANT_API_KEY is correct in repository secrets"
86+ ;;
87+ 404)
88+ echo "::error::Workflow not found (HTTP $http_code)"
89+ echo ""
90+ echo "Cause: The workflow 'ingestDocsWorkflow' does not exist at the endpoint"
91+ echo "To fix: Verify the workflow is deployed at ${RUNPOD_ASSISTANT_BASE_URL}"
92+ ;;
93+ 500|502|503|504)
94+ echo "::error::Server error (HTTP $http_code)"
95+ echo ""
96+ echo "Cause: The runpod-assistant service returned a server error"
97+ echo "To fix: Check if runpod-assistant is healthy at ${RUNPOD_ASSISTANT_BASE_URL}"
98+ ;;
99+ *)
100+ echo "::error::Unexpected error (HTTP $http_code)"
101+ echo ""
102+ echo "Cause: Unknown - see response body above"
103+ ;;
104+ esac
105+
106+ exit 1
80107
81108 # Triggers the actual ingestion on merge to main
82109 trigger-ingestion :
@@ -90,15 +117,32 @@ jobs:
90117 run : |
91118 set -euo pipefail
92119
120+ # Validate required configuration before attempting requests
121+ if [ -z "${RUNPOD_ASSISTANT_BASE_URL:-}" ]; then
122+ echo "::error::RUNPOD_ASSISTANT_BASE_URL is not configured"
123+ echo ""
124+ echo "To fix: Go to Settings > Secrets and variables > Actions > Variables"
125+ echo "Add a variable named RUNPOD_ASSISTANT_BASE_URL with the Mastra endpoint URL"
126+ exit 1
127+ fi
128+
129+ if [ -z "${RUNPOD_ASSISTANT_API_KEY:-}" ]; then
130+ echo "::error::RUNPOD_ASSISTANT_API_KEY is not configured"
131+ echo ""
132+ echo "To fix: Go to Settings > Secrets and variables > Actions > Secrets"
133+ echo "Add a secret named RUNPOD_ASSISTANT_API_KEY with the API key"
134+ exit 1
135+ fi
136+
93137 RUN_ID=$(uuidgen | tr '[:upper:]' '[:lower:]')
94138 echo "Run ID: $RUN_ID"
95139
96140 make_request() {
97141 local endpoint="$1"
98142 local data="$2"
99- local description ="$3"
143+ local step_name ="$3"
100144
101- echo "$description ..."
145+ echo "$step_name ..."
102146 response=$(curl -s -w "\n%{http_code}" --max-time 30 -X POST \
103147 "${RUNPOD_ASSISTANT_BASE_URL}/api/workflows/ingestDocsWorkflow/${endpoint}?runId=$RUN_ID" \
104148 -H "Content-Type: application/json" \
@@ -107,15 +151,42 @@ jobs:
107151
108152 http_code=$(echo "$response" | tail -n1)
109153 body=$(echo "$response" | sed '$d')
110- echo "Response: $body (HTTP $http_code)"
111154
112- if [ "$http_code" -ne 200 ]; then
113- echo "ERROR : $description failed "
114- exit 1
155+ if [ "$http_code" -eq 200 ]; then
156+ echo "Success : $body "
157+ return 0
115158 fi
159+
160+ # Provide specific error messages based on HTTP status
161+ echo "::error::$step_name failed with HTTP $http_code"
162+ echo ""
163+ echo "Response body: $body"
164+ echo ""
165+
166+ case "$http_code" in
167+ 401|403)
168+ echo "Cause: Authentication failed"
169+ echo "To fix: Verify RUNPOD_ASSISTANT_API_KEY is correct in repository secrets"
170+ ;;
171+ 404)
172+ echo "Cause: Workflow 'ingestDocsWorkflow' not found"
173+ echo "To fix: Verify the workflow is deployed at ${RUNPOD_ASSISTANT_BASE_URL}"
174+ ;;
175+ 500|502|503|504)
176+ echo "Cause: Server error at ${RUNPOD_ASSISTANT_BASE_URL}"
177+ echo "To fix: Check if runpod-assistant is healthy; retry the workflow"
178+ ;;
179+ *)
180+ echo "Cause: Unexpected error"
181+ echo "To fix: Check the response body above for details"
182+ ;;
183+ esac
184+
185+ exit 1
116186 }
117187
118188 make_request "create-run" '{}' "Creating workflow run"
119189 make_request "start" '{"inputData": {"branch": "main"}}' "Starting workflow run"
120190
191+ echo ""
121192 echo "Successfully triggered docs ingestion workflow"
0 commit comments