Files
actions/github-deploy/bin/deployment-create-status
2019-06-05 15:21:42 -04:00

34 lines
941 B
Bash
Executable File

#!/bin/sh
#
# Usage:
# deployment-create-status <state> <description>
#
# 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"
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" \
-H "Accept: application/vnd.github.flash-preview+json" \
-d @- <<EOF
{
"state": "${DEPLOY_STATE}",
"target_url": "${GITHUB_URL}/${GITHUB_REPOSITORY}/actions",
"description": "${DEPLOY_DESC}"
}
EOF