Skip to content

Commit

Permalink
fix npm publish workaround
Browse files Browse the repository at this point in the history
error code was 409, not 429 (thanks eyesight!), also redid the logic to take into account how bash handles conditional functions, and added more expression so if npm returns a different exit status we can know what we need to do
  • Loading branch information
balupton authored Dec 28, 2023
1 parent 9a33bf5 commit 8a315df
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions action.bash
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,26 @@ fi
# workaround:
# https://github.com/bevry/trim-empty-keys/actions/runs/7299137279/job/19891492043
# https://github.com/bevry/oneday/actions/runs/7338411137/job/19980941727
# https://github.com/bevry/typechecker/actions/runs/7349089133/job/20008437623
function npm_publish {
local delay status
delay="$((RANDOM%60))"
echo "waiting ${delay} seconds..."
sleep "$delay"
status=0 && npm publish "$@" || status=$?
if test "$?" -eq 429; then
npm_publish "$@"
fi
return "$status"
while true; do
delay="$((RANDOM%60))"
echo "waiting ${delay} seconds..."
sleep "$delay"
status=0 && npm publish "$@" || status=$?
if test "$status" -eq 0; then
echo "npm publish successful"
break
elif test "$status" -eq 409; then
echo "npm publish failed with conflict, trying again..."
continue
else
echo "npm publish failed with exit status: $status"
return "$status"
fi
done
return 0
}

# =====================================
Expand Down

0 comments on commit 8a315df

Please sign in to comment.