Skip to content

Commit 3c31f3d

Browse files
committed
build: updated workflow to use local when nx cloud is not available
1 parent e0277ad commit 3c31f3d

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/nodejs.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ jobs:
5555
run: |
5656
if [ -z "$NX_CLOUD_ACCESS_TOKEN" ]; then
5757
echo "NX Cloud token missing — using local nx execution"
58-
echo "NX_CLOUD_DISTRIBUTED_EXECUTION=false" >> $GITHUB_ENV
58+
echo "NX_NO_CLOUD=true" >> $GITHUB_ENV
59+
echo "NX_CLOUD_STARTED=false" >> $GITHUB_ENV
5960
exit 0
6061
fi
6162
@@ -67,10 +68,21 @@ jobs:
6768
nx_cloud_started=false
6869
6970
until [ "$retries" -ge "$max_retries" ]; do
70-
if npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js"; then
71+
output=$(npx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" 2>&1)
72+
exit_code=$?
73+
74+
if echo "$output" | grep -q "401\|sufficient access\|unauthorized\|Unauthorized"; then
75+
echo "NX Cloud auth failed (401) — falling back to local nx immediately"
76+
echo "NX_NO_CLOUD=true" >> $GITHUB_ENV
77+
echo "NX_CLOUD_STARTED=false" >> $GITHUB_ENV
78+
exit 0
79+
fi
80+
81+
if [ "$exit_code" -eq 0 ]; then
7182
nx_cloud_started=true
7283
break
7384
fi
85+
7486
echo "nx-cloud start failed (attempt $((retries + 1))/${max_retries}). Retrying in $((2 ** retries))s..."
7587
sleep $((2 ** retries))
7688
retries=$((retries + 1))
@@ -81,7 +93,7 @@ jobs:
8193
echo "NX_CLOUD_STARTED=true" >> $GITHUB_ENV
8294
else
8395
echo "nx-cloud start failed after ${max_retries} attempts — falling back to local nx"
84-
echo "NX_CLOUD_DISTRIBUTED_EXECUTION=false" >> $GITHUB_ENV
96+
echo "NX_NO_CLOUD=true" >> $GITHUB_ENV
8597
echo "NX_CLOUD_STARTED=false" >> $GITHUB_ENV
8698
fi
8799

0 commit comments

Comments
 (0)