Skip to content

Commit

Permalink
Merge pull request #18 from creative-commoners/pulls/1.1/auto-tag-dis…
Browse files Browse the repository at this point in the history
…patch

MNT Output json from api calls
  • Loading branch information
GuySartorelli authored Aug 18, 2023
2 parents f03a0c1 + f6e218f commit 933cdd5
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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 }}" \
Expand All @@ -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 }}"
Expand Down Expand Up @@ -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
Expand All @@ -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 }}" \
Expand All @@ -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

0 comments on commit 933cdd5

Please sign in to comment.