Commit 063ed3f2 authored by I-Al-Istannen's avatar I-Al-Istannen
Browse files

flammenwehrfer: Edit issue instead of posting comments

parent 85c2faa9
Pipeline #174046 failed with stage
in 6 minutes and 4 seconds
......@@ -22,6 +22,7 @@ fi
# \____\___/|_| |_|___/\__\__,_|_| |_|\__|___/
#
BODY="Greetings traveller,\n\nsticks and stones won't break your bones but https://git.scc.kit.edu/IPDSnelting/mjtest-tests broke your compiler :(\n\nHave fun and take good care of it :lady_beetle:"
SUCCESS_CLOSING_BODY="Greetings traveller,\n\nall tests succeeded. Well done!\n\n<img src=\"https://c.tenor.com/EHpQyFzthQ4AAAAd/kalm-calm.gif\" width=\"300px\">\n\nEnjoy your day :lady_beetle:"
GITHUB_URL="https://api.github.com/repos/$GITHUB_PATH"
......@@ -36,7 +37,7 @@ MJ_EXIT_CODE="$?"
if [[ "$USE_FLAMMENWEHRFER" != 1 ]] || [[ "$CI_COMMIT_BRANCH" != "master" ]]; then
echo "Flammenwehrfer disabled, checked for branch '$CI_COMMIT_BRANCH'"
echo -e "Output: $MJ_OUTPUT"
echo -e "Output:\n$MJ_OUTPUT"
exit $MJ_EXIT_CODE
fi
......@@ -70,7 +71,7 @@ if [[ "$MJ_EXIT_CODE" == "0" ]]; then
-H "Accept: application/vnd.github.v3+json" \
-u "$AUTH" \
"$GITHUB_URL/issues/$ISSUE_NUMBER" \
-d '{"state":"closed"}' \
-d "{\"state\":\"closed\", \"body\":$(echo -e "$SUCCESS_CLOSING_BODY" | jq -R -s)}" \
-o /dev/null
fi
exit 0
......@@ -87,6 +88,7 @@ echo "Test failed"
CODE_BLOCK_HEADER='```'
BODY="$BODY\n\n----\n\n<details>\n<summary>mjtest output</summary>\n\n$CODE_BLOCK_HEADER\n$MJ_OUTPUT\n$CODE_BLOCK_HEADER\n\n</details>"
BODY="$BODY\n\n----\n\n$CODE_BLOCK_HEADER\n$(fortune | cowsay -n)\n$CODE_BLOCK_HEADER"
if [[ "$ISSUE_COUNT" == "0" ]]; then
echo "Found no issues, creating new one"
......@@ -109,22 +111,14 @@ if [[ "$ISSUE_COUNT" == "0" ]]; then
fi
ISSUE_NUMBER="$(echo "$FETCHED_ISSUES" | jq ".[0].number")"
echo "Commenting on issue $ISSUE_NUMBER"
echo "Editing issue $ISSUE_NUMBER"
curl -Ss \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
-u "$AUTH" \
"$GITHUB_URL/issues/$ISSUE_NUMBER" \
-d '{"state":"open"}' \
-o /dev/null
curl -Ss \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
-u "$AUTH" \
"$GITHUB_URL/issues/$ISSUE_NUMBER/comments" \
-d "{\"body\":$(echo -e "$BODY" | jq -R -s)}" \
-d "{\"state\":\"open\", \"body\":$(echo -e "$BODY" | jq -R -s)}" \
-o /dev/null
exit $MJ_EXIT_CODE
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment