https://github.com/sharpvik/morty-cd
Simple Go tool for Continuous Integration and Continuous Deployment utilizing the power of GitHub webhooks.
https://github.com/sharpvik/morty-cd
Last synced: 11 months ago
JSON representation
Simple Go tool for Continuous Integration and Continuous Deployment utilizing the power of GitHub webhooks.
- Host: GitHub
- URL: https://github.com/sharpvik/morty-cd
- Owner: sharpvik
- Created: 2020-04-21T13:30:14.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-23T13:41:12.000Z (over 5 years ago)
- Last Synced: 2023-03-05T21:46:37.317Z (almost 3 years ago)
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Morty CD
Simple Go tool for Continuous Integration and Continuous Deployment utilizing
the power of GitHub webhooks.
## Prerequisites
- Install *Go* programming language.
## User Guide
### Setup On Machine
#### Get Source Code
```bash
go get github.com/sharpvik/morty-cd
```
#### Add Config File
This is how my `config.go` looks (you can just `Copy + Paste`):
```go
package main
import "os"
// port is a string that represents the port at which server will be listening
// for incoming requests.
const port = ":5050"
// logWriter implements the io.Writer interface and is used by the logr to
// output the data it logs.
var logWriter = os.Stdout
// var logWriter, _ = os.Create("/home/viktor/Public/Lisn/logs/morty-cd-lisn-web-app.log")
// logPrefix is a string that will be inserted before every log message.
const logPrefix = ""
```
#### Installation
To install this globally, you can do two things:
1. Add your `$(go env GOPATH)/bin` folder to `$PATH` and run `go install`
2. Run `go build` and then `mv morty-cd /usr/local/bin/` or to any other folder
registered within `$PATH`
### GitHub Webhooks Setup
Locate the GitHub repo you'd like to bind your `script` to. From there go
**Settings > Webhooks > Add webhook**. For **Payload URL** use your server's IP
address and port like so: `http://155.13.12.5:5050/github`. You must include the
`/github` at the end!
Set **Content type** to `application/json` and select the events you want to
trigger webhook notifications. Confirm.
> If you don't see some of the events you want included in the `handlers.go`
> file, it means you'll have to include them yourself and then modify the switch
> statement in the main handler function called `github`.
> If you do create some additional handlers, please share them with us!
### Run It
When you've properly installed the app and setup webhooks, go to the project you
want to monitor and run `morty-cd ./deploy.sh`. This step *assumes* that some
deployment script called `deploy.sh` is present within that folder and has
executive privileges.
> To give executive privileges to any script, specify its interpreter on the
> very first line by adding `#!/usr/bin/interpreter` add then run
> `chmod +x deploy.sh`. For example, if your script is a `bash` script, put
> `#!/usr/bin/bash` as your shebang.