fix: make curl fail fast on HTTP error
This commit is contained in:
+16
-10
@@ -70,13 +70,19 @@ handle_mr:
|
|||||||
--arg content "${CONTENT}" \
|
--arg content "${CONTENT}" \
|
||||||
--arg startBranch "${CI_DEFAULT_BRANCH}" \
|
--arg startBranch "${CI_DEFAULT_BRANCH}" \
|
||||||
"${BODY_TMPL}")"
|
"${BODY_TMPL}")"
|
||||||
curl -s -X PUT \
|
# Check if CHANGELOG.md exists
|
||||||
|
if curl -sf --head \
|
||||||
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/repository/files/CHANGELOG%2Emd?ref=next-release"; then
|
||||||
--data "${BODY}" \
|
# Exists => update
|
||||||
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/repository/files/CHANGELOG%2Emd"
|
curl -sf -X PUT \
|
||||||
if [ $? -ne 0 ]; then
|
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
||||||
curl -s -X POST \
|
-H "Content-Type: application/json" \
|
||||||
|
--data "${BODY}" \
|
||||||
|
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/repository/files/CHANGELOG%2Emd"
|
||||||
|
else
|
||||||
|
# Not exists => create
|
||||||
|
curl -sf -X POST \
|
||||||
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "${BODY}" \
|
--data "${BODY}" \
|
||||||
@@ -85,7 +91,7 @@ handle_mr:
|
|||||||
if [ -n "${MR}" ]; then
|
if [ -n "${MR}" ]; then
|
||||||
echo "Updating existing MR"
|
echo "Updating existing MR"
|
||||||
echo "Rebasing branch"
|
echo "Rebasing branch"
|
||||||
curl -s -X PUT \
|
curl -sf -X PUT \
|
||||||
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/merge_requests/${MR}/rebase"
|
"https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/merge_requests/${MR}/rebase"
|
||||||
@@ -95,7 +101,7 @@ handle_mr:
|
|||||||
--arg title "${TITLE}" \
|
--arg title "${TITLE}" \
|
||||||
--arg target "${CI_DEFAULT_BRANCH}" \
|
--arg target "${CI_DEFAULT_BRANCH}" \
|
||||||
"${BODY_TMPL}")
|
"${BODY_TMPL}")
|
||||||
curl -s -X PUT \
|
curl -sf -X PUT \
|
||||||
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "${BODY}" \
|
--data "${BODY}" \
|
||||||
@@ -107,7 +113,7 @@ handle_mr:
|
|||||||
--arg title "${TITLE}" \
|
--arg title "${TITLE}" \
|
||||||
--arg target "${CI_DEFAULT_BRANCH}" \
|
--arg target "${CI_DEFAULT_BRANCH}" \
|
||||||
"${BODY_TMPL}")
|
"${BODY_TMPL}")
|
||||||
curl -s -X POST \
|
curl -sf -X POST \
|
||||||
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "${BODY}" \
|
--data "${BODY}" \
|
||||||
@@ -162,7 +168,7 @@ release:
|
|||||||
--arg message "${MESSAGE}" \
|
--arg message "${MESSAGE}" \
|
||||||
--arg ref "${CI_DEFAULT_BRANCH}" \
|
--arg ref "${CI_DEFAULT_BRANCH}" \
|
||||||
"${BODY_TMPL}")"
|
"${BODY_TMPL}")"
|
||||||
curl -s -X POST \
|
curl -sf -X POST \
|
||||||
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
-H "Authorization: Bearer ${UNBOUND_RELEASE_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
--data "${BODY}" \
|
--data "${BODY}" \
|
||||||
|
|||||||
Reference in New Issue
Block a user