Files
actions/github-deploy
Tair Assimov 351774ade8 Pass deployment metadata when creating status (#9)
* Pass deployment metadata when creating status

- Set target_url to /actions
- Ability to pass a description
- Format post parameters

* Set default deploy description
2019-01-16 21:56:41 +01:00
..
2019-01-07 10:22:55 +01:00
2019-01-07 10:22:55 +01:00
2019-01-07 10:22:55 +01:00
2019-01-07 10:22:55 +01:00
2019-01-07 10:22:55 +01:00
2019-01-10 14:08:19 +01:00

github-deploy

This actions adds functions for interacting with Github Deployment API and a Workflow instantiated from a deployment event

Usage

The action installs functions in ${HOME}/bin, for which you can use in later actions which does the actual deploy. An example workflow might look this:

workflow "On deploy" {
  on = "deployment"
  resolves = ["Deploy"]
}

action "Add deployscripts" {
  uses = "unacast/actions/github-deploy@master"
}

action "Deploy" {
  uses = "docker://byrnedo/alpine-curl"
  secrets = ["GITHUB_TOKEN"]
  args = "./scripts/deploy.sh"
  needs = ["Add deployscripts"]
}

Furthermore, in the "deploy.sh" of your choice, you can utilize the following script commands from ${HOME}/bin:

deployment-get-environment

This gets the submitted environment from within ${GITHUB_EVENT_PATH}. For example production

deployment-get-id

This gets the created deployment-id from within ${GITHUB_EVENT_PATH}. Usually you won't have to deal with this, it is for most purposes used by deployment-set-status

deployment-exec-try

This runs the params submitted, and if error creates a error deployment status using deployment-create-status. This command can be used in deploy-scripts or as a entrypoint as so:

...

action "Add deployscripts" {
  uses = "unacast/actions/github-deploy@master"
}

action "Success" {
  uses = "docker://byrnedo/alpine-curl"
  args = "echo hallois"
  runs = "/github/home/bin/deployment-exec-try"
  secrets = ["GITHUB_TOKEN"]
  needs = ["Add deployscripts"]
}

action "This one failes and updates Deployment API with error" {
  uses = "docker://byrnedo/alpine-curl"
  args = "cd this-folder-does-not-exist"
  runs = "/github/home/bin/deployment-exec-try"
  secrets = ["GITHUB_TOKEN"]
  needs = ["Add deployscripts"]
}

Requires the container to have curl installed on failure.

deployment-create-status

This function updates the Deployment API with the result of your deploy. For example ${HOME}/bin/deployment-create-status success creates a success-status on the deployment event.

success can be replaced with the other allowed statuses (error, failure, inactive, in_progress, queued or pending) from the Create a deployment status endpoint

Requires the container to have curl installed.

License

The Dockerfile and associated scripts and documentation in this project are released under the MIT License and Apache 2.

It uses the excellent JSON.sh for json parsing.