From e101c39925a68ea0d576947cc57e42986a0651eb Mon Sep 17 00:00:00 2001 From: Esteban Martinena Guerrero Date: Fri, 29 Sep 2023 11:26:07 +0200 Subject: [PATCH] Post checking status (#11) * post checking status * Improve output --- action.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 5893ac6..491cc9d 100644 --- a/action.yml +++ b/action.yml @@ -73,4 +73,14 @@ runs: esac echo "⏁ Removing Runner from ZeroTier network" - curl -s -X DELETE -H "Authorization: token ${{ inputs.auth_token }}" "${{ inputs.api_url }}/network/${{ inputs.network_id }}/member/${member_id}" + curl -i -s -X DELETE -H "Authorization: token ${{ inputs.auth_token }}" "${{ inputs.api_url }}/network/${{ inputs.network_id }}/member/${member_id}" > /tmp/api_delete_output.txt + STATUS_CODE=$(cat /tmp/api_delete_output.txt | grep 'HTTP/' | awk '{print $2}') + + if [[ $STATUS_CODE -ge 400 && $STATUS_CODE -le 599 ]]; then + echo "ERROR: Status code: $STATUS_CODE" + echo -e "Complete server response:\n$(cat /tmp/api_delete_output.txt)\n" + exit $STATUS_CODE + else + echo "Success! Status code: $STATUS_CODE" + exit 0 + fi