From f6e218f725b5a42ba55eaea5fb75ac4c4346b733 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 17 Aug 2023 16:03:42 +1200 Subject: [PATCH] MNT Output json from api calls --- action.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index db0b4d6..9fe10f5 100644 --- a/action.yml +++ b/action.yml @@ -54,6 +54,7 @@ runs: RESP_MSG=$(jq -r .message __response.json) if [[ $RESP_MSG != "Not Found" ]]; then echo "Unable to check tag status for $TAG - HTTP response code was $RESP_CODE and message was $RESP_MSG" + cat __response.json exit 1 fi fi @@ -62,12 +63,13 @@ runs: echo "Did not find an existing release for tag $TAG" else # https://docs.github.com/en/rest/releases/releases#delete-a-release - RESP_CODE=$(curl -w %{http_code} -s -o /dev/null \ + RESP_CODE=$(curl -w %{http_code} -s -o __response.json \ -X DELETE https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token ${{ github.token }}") if [[ $RESP_CODE != "204" ]]; then echo "Unable to delete release $RELEASE_ID for tag $TAG - HTTP response code was $RESP_CODE" + cat __response.json exit 1 fi echo "Deleted existing release $RELEASE_ID for tag $TAG" @@ -89,6 +91,7 @@ runs: -H "Accept: application/vnd.github.v3+json") if [[ $RESP_CODE != "200" ]]; then echo "Unable to check tag status - HTTP response code was $RESP_CODE" + cat __response.json exit 1 fi FOUND="true" @@ -104,12 +107,13 @@ runs: else # Delete tag via GitHub API # https://docs.github.com/en/rest/reference/git#delete-a-reference - RESP_CODE=$(curl -w %{http_code} -s -o /dev/null \ + RESP_CODE=$(curl -w %{http_code} -s -o __response.json \ -X DELETE https://api.github.com/repos/$GITHUB_REPOSITORY/git/refs/tags/$TAG \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token ${{ github.token }}") if [[ $RESP_CODE != "204" ]]; then echo "Unable to delete existing TAG $TAG - HTTP response code was $RESP_CODE" + cat __response.json exit 1 fi echo "Deleted existing tag $TAG" @@ -126,7 +130,7 @@ runs: run: | # Create new tag via GitHub API # https://docs.github.com/en/rest/reference/git#create-a-reference - RESP_CODE=$(curl -w %{http_code} -s -o /dev/null \ + RESP_CODE=$(curl -w %{http_code} -s -o __response.json \ -X POST https://api.github.com/repos/$GITHUB_REPOSITORY/git/refs \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token ${{ github.token }}" \ @@ -139,6 +143,7 @@ runs: ) if [[ $RESP_CODE != "201" ]]; then echo "Unable to create tag $TAG for sha ${{ github.sha }} - HTTP response code was $RESP_CODE" + cat __response.json exit 1 fi echo "New tag $TAG created for sha ${{ github.sha }}" @@ -168,6 +173,7 @@ runs: ) if [[ $RESP_CODE != "200" ]]; then echo "Unable to read list of tags - HTTP response code was $RESP_CODE" + cat __response.json exit 1 fi # Get the latest stable tag @@ -188,7 +194,7 @@ runs: RELEASE_DESCRIPTION=${RELEASE_DESCRIPTION//\"/\\\"} # Create new release via GitHub API # https://docs.github.com/en/rest/releases/releases#create-a-release - RESP_CODE=$(curl -w %{http_code} -s -o /dev/null \ + RESP_CODE=$(curl -w %{http_code} -s -o __response.json \ -X POST https://api.github.com/repos/$GITHUB_REPOSITORY/releases \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token ${{ github.token }}" \ @@ -207,6 +213,15 @@ runs: ) if [[ $RESP_CODE != "201" ]]; then echo "Unable to create release for tag $TAG - HTTP response code was $RESP_CODE" + cat __response.json exit 1 fi echo "New release $TAG created" + + - name: Delete temporary files + shell: bash + if: always() + run: | + if [[ -f __response.json ]]; then + rm __response.json + fi