Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marwan-at-work/minicd
A Go HandlerFunc That Makes Your Go Server Self-Deployable
https://github.com/marwan-at-work/minicd
continuous-delivery golang
Last synced: 2 days ago
JSON representation
A Go HandlerFunc That Makes Your Go Server Self-Deployable
- Host: GitHub
- URL: https://github.com/marwan-at-work/minicd
- Owner: marwan-at-work
- Created: 2017-07-29T23:00:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-30T15:03:07.000Z (over 7 years ago)
- Last Synced: 2024-11-06T01:57:49.573Z (about 2 months ago)
- Topics: continuous-delivery, golang
- Language: Go
- Homepage:
- Size: 3.66 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MiniCD
Package minicd exposes an `http.HandlerFunc` that you can include in your Go web server so it can continuously deliver itself whenever you push to Github.
This is meant for small personal projects and I wouldn't recommend it for large production apps. For larger scale CI/CD check out [baghdad](https://www.github.com/marwan-at-work/baghdad).
## Usage
```go
package mainimport (
"context"
"fmt"
"net/http""github.com/marwan-at-work/minicd"
)func main() {
killSig := make(chan context.Context)http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "hello world")
})http.HandleFunc("/github-hook", minicd.Handler(minicd.Config{
WebhookSecret: "my_webhook_secret",
GithubToken: "optional_if_public_repo",
KillSig: killSig,
}))srv := &http.Server{Addr: ":3000"}
go func() {
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Fatal(err)
}
}()err := srv.Shutdown(<-killSig)
if err != nil {
log.Fatal(err)
}fmt.Println("see ya on the other updated side")
}```
### Gotchas
This doesn't work with a local Docker container because spinning a new process inside the container doesn't keep the container alive if the original process was killed.
As a to-do, this could work with a swarm cluster.