mirror of
https://github.com/zhigang1992/actions.git
synced 2026-01-12 22:45:39 +08:00
* Pass deployment metadata when creating status - Set target_url to /actions - Ability to pass a description - Format post parameters * Set default deploy description
33 lines
880 B
Bash
Executable File
33 lines
880 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" \
|
|
-d @- <<EOF
|
|
{
|
|
"state": "${DEPLOY_STATE}",
|
|
"target_url": "${GITHUB_URL}/${GITHUB_REPOSITORY}/actions",
|
|
"description": "${DEPLOY_DESC}"
|
|
}
|
|
EOF
|