diff --git a/github-deploy/bin/deployment-create-status b/github-deploy/bin/deployment-create-status index da13369..09a02a4 100755 --- a/github-deploy/bin/deployment-create-status +++ b/github-deploy/bin/deployment-create-status @@ -1,9 +1,32 @@ #!/bin/sh +# +# Usage: +# deployment-create-status +# +# Arguments: +# $1 - The deployment state +# $2 - The deployment description +# BASEDIR=$(dirname "$0") DEPLOYMENT_ID=$("${BASEDIR}"/deployment-get-id) +GITHUB_URL="https://github.com" +GITHUB_API_URL="https://api.github.com" -echo "Setting status to ${1} for deployment-id '${DEPLOYMENT_ID}'" -curl --silent --show-error --fail -X POST -H "Authorization: token ${GITHUB_TOKEN}" \ - --data '{"state":"'"${1}"'"}' \ - "https://api.github.com/repos/${GITHUB_REPOSITORY}/deployments/${DEPLOYMENT_ID}/statuses" \ No newline at end of file +DEPLOY_STATE="${1}" +DEPLOY_DESC="${2}" + +[ -n "${DEPLOY_DESC}" ] || DEPLOY_DESC="Deploying from GitHub Actions" + +echo "Setting status to ${DEPLOY_STATE} for deployment-id '${DEPLOYMENT_ID}'" +curl --silent --show-error --fail \ + -X POST "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/deployments/${DEPLOYMENT_ID}/statuses" \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Content-Type: text/json; charset=utf-8" \ + -d @- <