Added script errors
This commit is contained in:
parent
a35dc6f10e
commit
307f480f7b
86
plugin.sh
86
plugin.sh
@ -1,42 +1,66 @@
|
|||||||
#!/busybox/sh
|
#!/busybox/sh
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
git fetch
|
# git fetch
|
||||||
|
|
||||||
CURRENTTAG=$(git tag --sort=-taggerdate | head -n 1)
|
CURRENTTAG=$(git tag --sort=-taggerdate | head -n 1)
|
||||||
PREVIOUSTAG=$(git tag --sort=-taggerdate | head -n 2 | tail -n 1)
|
PREVIOUSTAG=$(git tag --sort=-taggerdate | head -n 2 | tail -n 1)
|
||||||
ALLCHANGES=$(npx -y @philippdormann/changelogen@latest --from $PREVIOUSTAG --to $CURRENTTAG --no-output | sed 's/"/\\"/g' | tail -n +6)
|
ALLCHANGES=$(npx -y @philippdormann/changelogen@latest --from $PREVIOUSTAG --to $CURRENTTAG --no-output | sed 's/"/\\"/g' | tail -n +6)
|
||||||
FORMATTED_CHANGES=$(echo "# $CURRENTTAG \n $ALLCHANGES" | pandoc -f markdown -t html | sed 's/"/'"'"'/g' | xargs echo -n)
|
FORMATTED_CHANGES=$(echo "# $CURRENTTAG \n $ALLCHANGES" | pandoc -f markdown -t html | sed 's/"/'"'"'/g' | xargs echo -n)
|
||||||
|
|
||||||
if [[ -n "${PLUGIN_GITEA_DOMAIN:-}" ]]; then
|
echo $PLUGIN_GITEA_DOMAIN;
|
||||||
curl --request POST \
|
|
||||||
--url "https://$PLUGIN_GITEA_DOMAIN/api/v1/repos/$PLUGIN_REPO/releases" \
|
if [[ "${PLUGIN_GITEA_DOMAIN:-}" == "true" ]]; then
|
||||||
--header "Content-Type: application/json" \
|
if [[ -n "${PLUGIN_GITEA_APIKEY:-}"]]
|
||||||
--header "Authorization: token $APIKEY" \
|
echo "No api key provided";
|
||||||
--data "{
|
exit 1;
|
||||||
\"name\": \"$DRONE_TAG\",
|
fi
|
||||||
\"body\": \"$ALLCHANGES\",
|
if [[ -n "${PLUGIN_REPO:-}"]]
|
||||||
\"draft\": false,
|
echo "No repo provided";
|
||||||
\"tag_name\": \"$DRONE_TAG\"
|
exit 2;
|
||||||
}"
|
fi
|
||||||
|
|
||||||
|
curl --request POST \
|
||||||
|
--url "https://$PLUGIN_GITEA_DOMAIN/api/v1/repos/$PLUGIN_REPO/releases" \
|
||||||
|
--header "Content-Type: application/json" \
|
||||||
|
--header "Authorization: token $PLUGIN_GITEA_APIKEY" \
|
||||||
|
--data "{
|
||||||
|
\"name\": \"$CURRENTTAG\",
|
||||||
|
\"body\": \"$ALLCHANGES\",
|
||||||
|
\"draft\": false,
|
||||||
|
\"tag_name\": \"$CURRENTTAG\"
|
||||||
|
}"
|
||||||
fi
|
fi
|
||||||
if [[ -n "${PLUGIN_MATRIX_SERVER:-}" ]]; then
|
if [[ "${PLUGIN_MATRIX_SERVER:-}" == "true" ]]; then
|
||||||
MATRIX_LOGIN=$(curl --request POST \
|
if [[ -n "${PLUGIN_MATRIX_USER:-}"]]
|
||||||
--url "https://$PLUGIN_MATRIX_SERVER/_matrix/client/r0/login" \
|
echo "No matrix username provided";
|
||||||
--header "Content-Type: application/json" \
|
exit 3;
|
||||||
--data "{
|
fi
|
||||||
\"type\": \"m.login.password\",
|
if [[ -n "${PLUGIN_MATRIX_PASSWORD:-}"]]
|
||||||
\"user\": \"$PLUGIN_MATRIX_USER\",
|
echo "No matrix password provided";
|
||||||
\"password\": \"$PLUGIN_MATRIX_PASSWORD\"
|
exit 4;
|
||||||
}")
|
fi
|
||||||
MATRIX_TOKEN=$(echo $MATRIX_LOGIN | jq .access_token | sed 's/"/\/g' )
|
if [[ -n "${PLUGIN_MATRIX_ROOM:-}"]]
|
||||||
curl --request POST \
|
echo "No matrix room id provided";
|
||||||
--url "https://$PLUGIN_MATRIX_SERVER/_matrix/client/r0/rooms/!YHENYmWYHrPltyHVeb:matrix.org/send/m.room.message?access_token=$MATRIX_TOKEN" \
|
exit 4;
|
||||||
--header "Content-Type: application/json" \
|
fi
|
||||||
--data "{
|
|
||||||
\"msgtype\": \"m.text\",
|
MATRIX_LOGIN=$(curl --request POST \
|
||||||
\"body\": \"$(echo "# $CURRENTTAG \n $ALLCHANGES" | xargs echo -n)\",
|
--url "https://$PLUGIN_MATRIX_SERVER/_matrix/client/r0/login" \
|
||||||
\"format\": \"org.matrix.custom.html\",
|
--header "Content-Type: application/json" \
|
||||||
\"formatted_body\": \"$FORMATTED_CHANGES\"
|
--data "{
|
||||||
}"
|
\"type\": \"m.login.password\",
|
||||||
|
\"user\": \"$PLUGIN_MATRIX_USER\",
|
||||||
|
\"password\": \"$PLUGIN_MATRIX_PASSWORD\"
|
||||||
|
}")
|
||||||
|
MATRIX_TOKEN=$(echo $MATRIX_LOGIN | jq .access_token | sed 's/"/\/g' )
|
||||||
|
curl --request POST \
|
||||||
|
--url "https://$PLUGIN_MATRIX_SERVER/_matrix/client/r0/rooms/$PLUGIN_MATRIX_ROOM/send/m.room.message?access_token=$MATRIX_TOKEN" \
|
||||||
|
--header "Content-Type: application/json" \
|
||||||
|
--data "{
|
||||||
|
\"msgtype\": \"m.text\",
|
||||||
|
\"body\": \"$(echo "# $CURRENTTAG \n $ALLCHANGES" | xargs echo -n)\",
|
||||||
|
\"format\": \"org.matrix.custom.html\",
|
||||||
|
\"formatted_body\": \"$FORMATTED_CHANGES\"
|
||||||
|
}"
|
||||||
fi
|
fi
|
Loading…
x
Reference in New Issue
Block a user