10000 Initial implementation (#1) · cloudposse/github-status-updater@4867701 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4867701

Browse files
authored
Initial implementation (#1)
* Init * Add `Dockerfile` and build scripts * Update `Dockerfile` and scripts * Remove the obsolete godep * Update files * Update `Dockerfile` and `README` * Update `README` * Update `README` * Update `README` * Update `README` * Update `README` * Update `README` * Add `Makefile` * Update `README` * Update `README` * Update `Dockerfile` * Add `.travis.yml` * Update `README` * Use `-` instead of `_` in all `Makefile` target names * Update `Makefile` and scripts * Update `.travis.yml` * Add examples
1 parent 0a5238a commit 4867701

15 files changed

+443
-3
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
.idea
2+
*.iml
3+
dist/bin/*
4+
github-commit-status
5+
.build-harness
6+
17
# Binaries for programs and plugins
28
*.exe
39
*.dll

.travis.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
language: go
2+
go:
3+
- 1.9.x
4+
addons:
5+
apt:
6+
packages:
7+
- git
8+
- make
9+
- curl
10+
11+
install:
12+
- make init
13+
- make go:deps-build
14+
- make go:deps-dev
15+
- make go-get
16+
17+
script:
18+
- make go:deps
19+
- make go:test
20+
- make go:lint
21+
- make go:build-all
22+
- ls -l release/
23+
24+
deploy:
25+
provider: releases
26+
api_key: "$GITHUB_API_KEY"
27+
file_glob: true
28+
file: "release/*"
29+
skip_cleanup: true
30+
on:
31+
tags: true

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM golang:1.9.3 as builder
2+
RUN mkdir -p /go/src/github.com/cloudposse/github-commit-status
3+
WORKDIR /go/src/github.com/cloudposse/github-commit-status
4+
COPY . .
5+
RUN go get && CGO_ENABLED=0 go build -v -o "./dist/bin/github-commit-status" *.go
6+
7+
8+
FROM alpine:3.6
9+
RUN apk add --no-cache ca-certificates
10+
COPY --from=builder /go/src/github.com/cloudposse/github-commit-status/dist/bin/github-commit-status /usr/bin/github-commit-status
11+
ENV PATH $PATH:/usr/bin
12+
ENTRYPOINT ["github-commit-status"]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2018 Cloud Posse, LLC
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
SHELL = /bin/bash
2+
3+
PATH:=$(PATH):$(GOPATH)/bin
4+
5+
include $(shell curl --silent -o .build-harness "https://raw.githubusercontent.com/cloudposse/build-harness/master/templates/Makefile.build-harness"; echo .build-harness)
6+
7+
8+
.PHONY : go-get
9+
go-get:
10+
go get
11+
12+
13+
.PHONY : go-build
14+
go-build: go-get
15+
CGO_ENABLED=0 go build -v -o "./dist/bin/github-commit-status" *.go

README.md

Lines changed: 218 additions & 2 deletions
E377
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,218 @@
1-
# github-commit-status
2-
CLI to update the status of a GitHub commit
1+
# github-commit-status [![Build Status](https://travis-ci.org/cloudposse/github-commit-status.svg)](https://travis-ci.org/cloudposse/github-commit-status)
2+
3+
4+
Command line utility for setting or updating GitHub commit status.
5+
6+
![GitHub Commit Status Update](images/GitHub_Commit_Status_Update.png)
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+
### 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/

examples/example.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
GITHUB_TOKEN=XXXXXXXXXXXXXXXX
2+
GITHUB_OWNER=cloudposse
3+
GITHUB_REPO=github-commit-status
4+
GITHUB_COMMIT_SHA=XXXXXXXXXXXXXXXX
5+
GITHUB_COMMIT_STATE=success
6+
GITHUB_COMMIT_CONTEXT=CI
7+
GITHUB_COMMIT_DESCRIPTION="Commit status with target URL"
8+
GITHUB_COMMIT_TARGET_URL=https://my.buildstatus.com/build/3

examples/run_docker_with_env_vars.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
docker run -i --rm \
4+
-e GITHUB_TOKEN=XXXXXXXXXXXXXXXX \
5+
-e GITHUB_OWNER=cloudposse \
6+
-e GITHUB_REPO=github-commit-status \
7+
-e GITHUB_COMMIT_SHA=XXXXXXXXXXXXXXXX \
8+
-e GITHUB_COMMIT_STATE=success \
9+
-e GITHUB_COMMIT_CONTEXT=CI \
10+
-e GITHUB_COMMIT_DESCRIPTION="Commit status with target URL" \
11+
-e GITHUB_COMMIT_TARGET_URL=https://my.buildstatus.com/build/3 \
12+
github-commit-status
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker run -i --rm --env-file ./example.env github-commit-status
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
export GITHUB_TOKEN=XXXXXXXXXXXXXXXX
4+
export GITHUB_OWNER=cloudposse
5+
export GITHUB_REPO=github-commit-status
6+
export GITHUB_COMMIT_SHA=XXXXXXXXXXXXXXXX
7+
export GITHUB_COMMIT_STATE=success
8+
export GITHUB_COMMIT_CONTEXT=CI
9+
export GITHUB_COMMIT_DESCRIPTION="Commit status with target URL"
10+
export GITHUB_COMMIT_TARGET_URL=https://my.buildstatus.com/build/3
11+
12+
docker run -i --rm \
13+
-e GITHUB_TOKEN \
14+
-e GITHUB_OWNER \
15+
-e GITHUB_REPO \
16+
-e GITHUB_COMMIT_SHA \
17+
-e GITHUB_COMMIT_STATE \
18+
-e GITHUB_COMMIT_CONTEXT \
19+
-e GITHUB_COMMIT_DESCRIPTION \
20+
-e GITHUB_COMMIT_TARGET_URL \
21+
github-commit-status
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
../dist/bin/github-commit-status \
4+
-token XXXXXXXXXXXXXXXX \
5+
-owner cloudposse \
6+
-repo github-commit-status \
7+
-sha XXXXXXXXXXXXXXX \
8+
-state success \
9+
-context CI \
10+
-description "Commit status with target URL" \
11+
-url https://my.buildstatus.com/build/3

examples/run_locally_with_env_vars.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
export GITHUB_TOKEN=XXXXXXXXXXXXXXXX
4+
export GITHUB_OWNER=cloudposse
5+
export GITHUB_REPO=github-commit-status
6+
export GITHUB_COMMIT_SHA=XXXXXXXXXXXXXXXX
7+
export GITHUB_COMMIT_STATE=success
8+
export GITHUB_COMMIT_CONTEXT=CI
9+
export GITHUB_COMMIT_DESCRIPTION="Commit status with target URL"
10+
export GITHUB_COMMIT_TARGET_URL=https://my.buildstatus.com/build/3
11+
12+
../dist/bin/github-commit-status

glide.yaml

Whitespace-only changes.
40.4 KB
Loading

0 commit comments

Comments
 (0)
0