|
1 |
| -# github-commit-status |
2 |
| -CLI to update the status of a GitHub commit |
| 1 | +# github-commit-status [](https://travis-ci.org/cloudposse/github-commit-status) |
| 2 | + |
| 3 | + |
| 4 | +Command line utility for setting or updating GitHub commit status. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +Useful for CI environments like Travis, Circle or CodeFresh to set more specific commit statuses, including setting the target URL (the URL of the page representing the status). |
| 10 | + |
| 11 | +It accepts parameters as command-line arguments or as ENV variables. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +__NOTE__: Create a [GitHub token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) with `repo:status` scope |
| 16 | + |
| 17 | + |
| 18 | +__NOTE__: `-state` or `GITHUB_COMMIT_STATE` must be one of `error`, `failure`, `pending`, `success` |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | + |
| 25 | +### Build Go program locally |
| 26 | + |
| 27 | +```sh |
| 28 | +go get |
| 29 | + |
| 30 | +CGO_ENABLED=0 go build -v -o "./dist/bin/github-commit-status" *.go |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | +### Run locally with ENV vars |
| 35 | +[run_locally_with_env_vars.sh](examples/run_locally_with_env_vars.sh) |
| 36 | + |
| 37 | +```sh |
| 38 | +export GITHUB_TOKEN=XXXXXXXXXXXXXXXX |
| 39 | +export GITHUB_OWNER=cloudposse |
| 40 | +export GITHUB_REPO=github-commit-status |
| 41 | +export GITHUB_COMMIT_SHA=XXXXXXXXXXXXXXXX |
| 42 | +export GITHUB_COMMIT_STATE=success |
| 43 | +export GITHUB_COMMIT_CONTEXT=CI |
| 44 | +export GITHUB_COMMIT_DESCRIPTION="Commit status with target URL" |
| 45 | +export GITHUB_COMMIT_TARGET_URL=https://my.buildstatus.com/build/3 |
| 46 | + |
| 47 | +./dist/bin/github-commit-status |
| 48 | +``` |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +### Run locally with command-line arguments |
| 53 | +[run_locally_with_command_line_args.sh](examples/run_locally_with_command_line_args.sh) |
| 54 | + |
| 55 | +```sh |
| 56 | +./dist/bin/github-commit-status \ |
| 57 | + -token XXXXXXXXXXXXXXXX \ |
| 58 | + -owner cloudposse \ |
| 59 | + -repo github-commit-status \ |
| 60 | + -sha XXXXXXXXXXXXXXX \ |
| 61 | + -state success \ |
| 62 | + -context CI \ |
| 63 | + -description "Commit status with target URL" \ |
| 64 | + -url https://my.buildstatus.com/build/3 |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +### Build Docker container |
| 70 | +__NOTE__: it will download all `Go` dependencies and then build the program inside the container (see [`Dockerfile`](Dockerfile)) |
| 71 | + |
| 72 | + |
| 73 | +```sh |
| 74 | +docker build --tag github-commit-status --no-cache=true . |
| 75 | +``` |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 |
E377
+### Run in Docker container with ENV vars |
| 80 | +[run_docker_with_env_vars.sh](examples/run_docker_with_env_vars.sh) |
| 81 | + |
| 82 | +```sh |
| 83 | +docker run -i --rm \ |
| 84 | + -e GITHUB_TOKEN=XXXXXXXXXXXXXXXX \ |
| 85 | + -e GITHUB_OWNER=cloudposse \ |
| 86 | + -e GITHUB_REPO=github-commit-status \ |
| 87 | + -e GITHUB_COMMIT_SHA=XXXXXXXXXXXXXXXX \ |
| 88 | + -e GITHUB_COMMIT_STATE=success \ |
| 89 | + -e GITHUB_COMMIT_CONTEXT=CI \ |
| 90 | + -e GITHUB_COMMIT_DESCRIPTION="Commit status with target URL" \ |
| 91 | + -e GITHUB_COMMIT_TARGET_URL=https://my.buildstatus.com/build/3 \ |
| 92 | + github-commit-status |
| 93 | +``` |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +### Run in Docker container with local ENV vars propagated into the container's environment |
| 98 | +[run_docker_with_local_env_vars.sh](examples/run_docker_with_local_env_vars.sh) |
| 99 | + |
| 100 | +```sh |
| 101 | +export GITHUB_TOKEN=XXXXXXXXXXXXXXXX |
| 102 | +export GITHUB_OWNER=cloudposse |
| 103 | +export GITHUB_REPO=github-commit-status |
| 104 | +export GITHUB_COMMIT_SHA=XXXXXXXXXXXXXXXX |
| 105 | +export GITHUB_COMMIT_STATE=success |
| 106 | +export GITHUB_COMMIT_CONTEXT=CI |
| 107 | +export GITHUB_COMMIT_DESCRIPTION="Commit status with target URL" |
| 108 | +export GITHUB_COMMIT_TARGET_URL=https://my.buildstatus.com/build/3 |
| 109 | + |
| 110 | +docker run -i --rm \ |
| 111 | + -e GITHUB_TOKEN \ |
| 112 | + -e GITHUB_OWNER \ |
| 113 | + -e GITHUB_REPO \ |
| 114 | + -e GITHUB_COMMIT_SHA \ |
| 115 | + -e GITHUB_COMMIT_STATE \ |
| 116 | + -e GITHUB_COMMIT_CONTEXT \ |
| 117 | + -e GITHUB_COMMIT_DESCRIPTION \ |
| 118 | + -e GITHUB_COMMIT_TARGET_URL \ |
| 119 | + github-commit-status |
| 120 | +``` |
| 121 | + |
| 122 | + |
| 123 | + |
| 124 | +### Run in Docker container with ENV vars declared in a file |
| 125 | +[run_docker_with_env_vars_file.sh](examples/run_docker_with_env_vars_file.sh) |
| 126 | + |
| 127 | +```sh |
| 128 | +docker run -i --rm --env-file ./examples/example.env github-commit-status |
| 129 | +``` |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | +## References |
| 135 | +* https://github.com/google/go-github |
| 136 | +* https://docs.docker.com/develop/develop-images/dockerfile_best-practices |
| 137 | +* https://docs.docker.com/engine/reference/commandline/build |
| 138 | +* https://docs.docker.com/engine/reference/commandline/run/ |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | +## Help |
| 143 | + |
| 144 | +**Got a question?** |
| 145 | + |
| 146 | +File a GitHub [issue](https://github.com/cloudposse/github-commit-status/issues), send us an [email](mailto:hello@cloudposse.com) or reach out to us on [Gitter](https://gitter.im/cloudposse/). |
| 147 | + |
| 148 | + |
| 149 | +## Contributing |
| 150 | + |
| 151 | +### Bug Reports & Feature Requests |
| 152 | + |
| 153 | +Please use the [issue tracker](https://github.com/cloudposse/github-commit-status/issues) to report any bugs or file feature requests. |
| 154 | + |
| 155 | +### Developing |
| 156 | + |
| 157 | +If you are interested in being a contributor and want to get involved in developing `github-commit-status`, we would love to hear from you! Shoot us an [email](mailto:hello@cloudposse.com). |
| 158 | + |
| 159 | +In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. |
| 160 | + |
| 161 | + 1. **Fork** the repo on GitHub |
| 162 | + 2. **Clone** the project to your own machine |
| 163 | + 3. **Commit** changes to your own branch |
| 164 | + 4. **Push** your work back up to your fork |
| 165 | + 5. Submit a **Pull request** so that we can review your changes |
| 166 | + |
| 167 | +**NOTE:** Be sure to merge the latest from "upstream" before making a pull request! |
| 168 | + |
| 169 | + |
| 170 | +## License |
| 171 | + |
| 172 | +[APACHE 2.0](LICENSE) © 2018 [Cloud Posse, LLC](https://cloudposse.com) |
| 173 | + |
| 174 | +See [LICENSE](LICENSE) for full details. |
| 175 | + |
| 176 | + Licensed to the Apache Software Foundation (ASF) under one |
| 177 | + or more contributor license agreements. See the NOTICE file |
| 178 | + distributed with this work for additional information |
| 179 | + regarding copyright ownership. The ASF licenses this file |
| 180 | + to you under the Apache License, Version 2.0 (the |
| 181 | + "License"); you may not use this file except in compliance |
| 182 | + with the License. You may obtain a copy of the License at |
| 183 | + |
| 184 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 185 | + |
| 186 | + Unless required by applicable law or agreed to in writing, |
| 187 | + software distributed under the License is distributed on an |
| 188 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 189 | + KIND, either express or implied. See the License for the |
| 190 | + specific language governing permissions and limitations |
| 191 | + under the License. |
| 192 | + |
| 193 | + |
| 194 | +## About |
| 195 | + |
| 196 | +`github-commit-status` is maintained and funded by [Cloud Posse, LLC][website]. |
| 197 | + |
| 198 | +Like it? Please let us know at <hello@cloudposse.com> |
| 199 | + |
| 200 | +We love [Open Source Software](https://github.com/cloudposse/)! |
| 201 | + |
| 202 | +See [our other projects][community] |
| 203 | +or [hire us][hire] to help build your next cloud platform. |
| 204 | + |
| 205 | + [website]: https://cloudposse.com/ |
| 206 | + [community]: https://github.com/cloudposse/ |
| 207 | + [hire]: https://cloudposse.com/contact/ |
| 208 | + |
| 209 | + |
| 210 | +### Contributors |
| 211 | + |
| 212 | +| [![Erik Osterman][erik_img]][erik_web]<br/>[Erik Osterman][erik_web] | [![Andriy Knysh][andriy_img]][andriy_web]<br/>[Andriy Knysh][andriy_web] | |
| 213 | +|-------------------------------------------------------|------------------------------------------------------------------| |
| 214 | + |
| 215 | + [erik_img]: http://s.gravatar.com/avatar/88c480d4f73b813904e00a5695a454cb?s=144 |
| 216 | + [erik_web]: https://github.com/osterman/ |
| 217 | + [andriy_img]: https://avatars0.githubusercontent.com/u/7356997?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 |
| 218 | + [andriy_web]: https://github.com/aknysh/ |
0 commit comments