Create an exec try command (#8)

* Create an exec command

* Remove getting deployment_id

* Execute $* instead of first param

* Update README and rename command
This commit is contained in:
Ole Christian Langfjæran
2019-01-09 09:50:27 +01:00
committed by GitHub
parent debcd9e3f1
commit 3e74af75c8
2 changed files with 42 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ action "Add deployscripts" {
}
action "Deploy" {
uses = "docker://alpine"
uses = "docker://byrnedo/alpine-curl"
secrets = ["GITHUB_TOKEN"]
args = "./scripts/deploy.sh"
needs = ["Add deployscripts"]
@@ -32,11 +32,40 @@ This gets the submitted environment from within ${GITHUB_EVENT_PATH}. For exampl
### 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"
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"
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](https://developer.github.com/v3/repos/deployments/#create-a-deployment-status)
endpoint](https://developer.github.com/v3/repos/deployments/#create-a-deployment-status)
_Requires the container to have `curl` installed._
## License

View File

@@ -0,0 +1,11 @@
#!/bin/sh
BASEDIR=$(dirname "$0")
sh -c "$*"
RESULT=$?
if [[ 0 != "${RESULT}" ]];then
echo "Failed '$*'! Exit code '${RESULT}' is not equal to 0"
${BASEDIR}/deployment-create-status error
exit ${RESULT}
fi