changelog/plugins-available/output-changelog-server.sh

19 lines
955 B
Bash
Raw Normal View History

2020-05-17 23:10:06 +00:00
#!/bin/bash
# Sends the changelog information to a changelog server
# see https://git.interhacker.space/alban/changelog-server
# Requires environmental variables to work
# CHANGELOG_SERVER
# CHANGELOG_AUTH_KEY
PLUGIN_OUTPUT+=( hookOutputChangelogServer )
hookOutputChangelogServer(){
[[ -z "$1" ]] && echo "Sending changelog to remote server" && return
[[ -z "$CHANGELOG_SERVER" ]] && echo "Missing CHANGELOG_SERVER variable. Exiting." && return
[[ -z "$CHANGELOG_AUTH_KEY" ]] && echo "Missing CHANGELOG_AUTH_KEY variable. Exiting." && return
CONTENT=$(jq -aRs . $1|tr '"' '\"')
PAYLOAD="{\"author\":\"$CHANGELOG_USERNAME\",\"server\":\"$(hostname -f)\",\"content\":${CONTENT}}"
URL=$( curl -X POST -H "AuthorizationToken: $CHANGELOG_AUTH_KEY" -H "Content-Type: application/json" -s -d "${PAYLOAD}" "$CHANGELOG_SERVER/changelog/_doc"; )
[[ 0 -ne $? ]] && echo "Failed to upload the changelog..." && return
echo "$FILE: $URL" >> $TMP
}