9999 --header "Content-Type: application/x-www-form-urlencoded" \
100100 --header "AuthorizationBasic ${ASSISTANT_M2M_AUTH}" \
101101 --data "grant_type=client_credentials" \
102- "${ASSISTANT_M2M_URL}" -o response.json
102+ "${ASSISTANT_M2M_URL}" -o m2m_response.json || true
103+
104+ if [ ! -f "m2m_response.json" ]; then
105+ echo "Login via m2m has failed..."
106+ exit 0
107+ fi
103108
104109 # Ask assistant for a response
105110 jq -nS --arg title "${DISCUSSION_TITLE}" --arg body "${DISCUSSION_BODY}" '{
@@ -111,15 +116,20 @@ jobs:
111116 --proto '=https' \
112117 --tlsv1.2 \
113118 --request POST \
114- --header "Authorization: Bearer: $(jq -r '.access_token' response .json)" \
119+ --header "Authorization: Bearer: $(jq -r '.access_token' m2m_response .json)" \
115120 --header "Content-Type: application/json" \
116121 --data "@data.json" \
117- "${ASSISTANT_API_URL}" -o response.json
122+ "${ASSISTANT_API_URL}" -o assistant_response.json || true
123+
124+ if [ ! -f "assistant_response.json" ]; then
125+ echo "Assistant request has failed..."
126+ exit 0
127+ fi
118128
119129 # Send suggestion to the discussion thread
120130 jq -nS --arg threadNumber "${THREAD_NUMBER}" \
121- --arg message "$(jq -r '.message' response .json)" \
122- --arg referenceLinks "$(jq -r '[.references[].url] | join(\", \")' response .json)" \
131+ --arg message "$(jq -r '.message' assistant_response .json)" \
132+ --arg referenceLinks "$(jq -r '[.references[].url] | join(\", \")' assistant_response .json)" \
123133 '{
124134 thread: {
125135 threadKey: "\($threadNumber)",
0 commit comments