Skip to content

Instantly share code, notes, and snippets.

@homeyer
Last active February 15, 2018 08:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save homeyer/910c58b05b07a2255b37137b5c51810c to your computer and use it in GitHub Desktop.
Save homeyer/910c58b05b07a2255b37137b5c51810c to your computer and use it in GitHub Desktop.
#!/bin/bash
# Create a deployment
create_gh_deployment () {
curl -s -X POST "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/deployments" \
-H 'Content-Type: application/json' \
-H 'Accept: application/vnd.github.ant-man-preview+json' \
-u ${GITHUB_ACCESS_TOKEN} \
-d "{"ref": "${CIRCLE_SHA1}", "environment": "${environment}", "required_contexts": [], "auto_merge": false}"
}
# Run this function when you trigger a deploy.
# Keep track of the deployment id as $gh_deploy_id for later. We're using https://stedolan.github.io/jq/ to parse the JSON to grab the id.
declare -r created_gh_deployment=$(create_gh_deployment)
declare -r gh_deploy_id=$(echo $created_gh_deployment | jq .id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment