Compare commits
2 Commits
422fedf9cd
...
2abed91918
Author | SHA1 | Date |
---|---|---|
Urko. | 2abed91918 | |
Urko. | fe002edab1 |
27
README.md
27
README.md
|
@ -1,25 +1,35 @@
|
||||||
# git-webhook-ci
|
# git-webhook-ci
|
||||||
|
|
||||||
Tool to automatize your deploy based on file write changes
|
Tool to automatize your deploy based on file write changes
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
After some change is made in our listener file the script placed on path set on `env` variable called **WEBHOOK_SCRIPT_PATH** will be executed.
|
After some change is made in our listener file the script placed on path set on `env` variable called **WEBHOOK_SCRIPT_PATH** will be executed.
|
||||||
|
|
||||||
## Context
|
## Context
|
||||||
|
|
||||||
As a security risk that could be allow a webhook listener on a VPS for your git repository, I've decided
|
As a security risk that could be allow a webhook listener on a VPS for your git repository, I've decided
|
||||||
to create this package which is a listener to file changes on write. This will trigger a bash script which
|
to create this package which is a listener to file changes on write. This will trigger a bash script which
|
||||||
you shold place on your server to run desired tasks. In my case I've done this to run a bash deploy command like
|
you shold place on your server to run desired tasks. In my case I've done this to run a bash deploy command like
|
||||||
- git pull
|
|
||||||
- build
|
- git pull
|
||||||
- move build to desired dir
|
- build
|
||||||
- restart services like nginx or whatever
|
- move build to desired dir
|
||||||
|
- restart services like nginx or whatever
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Requirements
|
### Requirements
|
||||||
|
|
||||||
- [Go version > 1.19](https://go.dev/dl/)
|
- [Go version > 1.19](https://go.dev/dl/)
|
||||||
- [GNU Make 4.3](https://www.gnu.org/software/make/)
|
- [GNU Make 4.3](https://www.gnu.org/software/make/)
|
||||||
- [goreportcard-cli](https://github.com/gojp/goreportcard)
|
- [goreportcard-cli](https://github.com/gojp/goreportcard)
|
||||||
- [golangci-lint](https://golangci-lint.run/)
|
- [golangci-lint](https://golangci-lint.run/)
|
||||||
|
|
||||||
### Environment Vars
|
### Environment Vars
|
||||||
|
|
||||||
As shown in .env.example you have to configure this variables in order to make your binary works right:
|
As shown in .env.example you have to configure this variables in order to make your binary works right:
|
||||||
|
|
||||||
```.env
|
```.env
|
||||||
SCRIPT_BINARY_PATH=/bin/bash
|
SCRIPT_BINARY_PATH=/bin/bash
|
||||||
WEBHOOK_SCRIPT_PATH=/path/to/mybashscript.sh
|
WEBHOOK_SCRIPT_PATH=/path/to/mybashscript.sh
|
||||||
|
@ -30,17 +40,23 @@ TEST_FILE_TO_WATCH_PATH=./test_monitor.txt
|
||||||
**TEST_FILE_TO_WATCH_PATH** is needed just to run tests
|
**TEST_FILE_TO_WATCH_PATH** is needed just to run tests
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
### Build
|
### Build
|
||||||
|
|
||||||
To build you can only just `make build` command
|
To build you can only just `make build` command
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make build
|
make build
|
||||||
```
|
```
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make test-coverage
|
make test-coverage
|
||||||
```
|
```
|
||||||
|
|
||||||
output:
|
output:
|
||||||
|
|
||||||
```terminal
|
```terminal
|
||||||
coverage: 80.0% of statements
|
coverage: 80.0% of statements
|
||||||
ok gitea.urkob.com/urko/git-webhook-ci/internal/watcher 2.024s coverage: 80.0% of statements
|
ok gitea.urkob.com/urko/git-webhook-ci/internal/watcher 2.024s coverage: 80.0% of statements
|
||||||
|
@ -49,6 +65,7 @@ ok gitea.urkob.com/urko/git-webhook-ci/pkg/watcher 0.017s coverage: 100.0%
|
||||||
```
|
```
|
||||||
|
|
||||||
## goreportcard
|
## goreportcard
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
➜ git-webhook-ci git:(main) ✗ make goreportcard
|
➜ git-webhook-ci git:(main) ✗ make goreportcard
|
||||||
oreportcard-cli -v
|
oreportcard-cli -v
|
||||||
|
@ -61,4 +78,4 @@ gocyclo ............. 100%
|
||||||
ineffassign ......... 100%
|
ineffassign ......... 100%
|
||||||
license ............. 100%
|
license ............. 100%
|
||||||
misspell ............ 100%
|
misspell ............ 100%
|
||||||
```
|
```
|
||||||
|
|
7
go.mod
7
go.mod
|
@ -1,18 +1,17 @@
|
||||||
module gitea.urkob.com/urko/git-webhook-ci
|
module gitea.urkob.com/urko/git-webhook-ci
|
||||||
|
|
||||||
go 1.19
|
go 1.22
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/fsnotify/fsnotify v1.6.0
|
github.com/fsnotify/fsnotify v1.7.0
|
||||||
github.com/joho/godotenv v1.5.1
|
github.com/joho/godotenv v1.5.1
|
||||||
github.com/kelseyhightower/envconfig v1.4.0
|
github.com/kelseyhightower/envconfig v1.4.0
|
||||||
github.com/stretchr/testify v1.8.2
|
github.com/stretchr/testify v1.8.2
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
gitea.urkob.com/urko/go-root-dir v0.0.0-20230226084401-f50cf1a3ecf4 // indirect
|
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
|
golang.org/x/sys v0.19.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
10
go.sum
10
go.sum
|
@ -1,10 +1,8 @@
|
||||||
gitea.urkob.com/urko/go-root-dir v0.0.0-20230226084401-f50cf1a3ecf4 h1:MW/orsvrClFsnh23qbDiU+D5Kg/AWcBQE3WPzrBmKl4=
|
|
||||||
gitea.urkob.com/urko/go-root-dir v0.0.0-20230226084401-f50cf1a3ecf4/go.mod h1:tEv2tp+/KhJt9OiaLpq8Ln81FtkADpeTH5nJxl8UFUA=
|
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
|
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||||
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
|
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
|
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
|
||||||
|
@ -18,8 +16,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956 h1:XeJjHH1KiLpKGb6lvMiksZ9l0fVUh+AmGcm0nOMEBOY=
|
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|
Loading…
Reference in New Issue