You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Urko 422fedf9cd
fix: test
9 months ago
cfg feat: use env path as parameter 9 months ago
internal/watcher fix: test 9 months ago
pkg/watcher feat: complete tests 10 months ago
.env.example feat: add .env.example 10 months ago
.gitignore feat: update gitignore 10 months ago
LICENSE feature: add license 10 months ago
Makefile feat: upgrade makefile 10 months ago
README.md feature: update readme 10 months ago
go.mod feat: get envfile from path when is not prod 9 months ago
go.sum feat: get envfile from path when is not prod 9 months ago
main.go feat: get envfile from path when is not prod 9 months ago
test-script.sh feat: log event 10 months ago

README.md

git-webhook-ci

Tool to automatize your deploy based on file write changes

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.

Context

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 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
  • move build to desired dir
  • restart services like nginx or whatever

Installation

Requirements

Environment Vars

As shown in .env.example you have to configure this variables in order to make your binary works right:

SCRIPT_BINARY_PATH=/bin/bash
WEBHOOK_SCRIPT_PATH=/path/to/mybashscript.sh
FILE_TO_WATCH_PATH=/path/to/myfile.txt
TEST_FILE_TO_WATCH_PATH=./test_monitor.txt

TEST_FILE_TO_WATCH_PATH is needed just to run tests

How to use

Build

To build you can only just make build command

make build

Tests

make test-coverage

output:

coverage: 80.0% of statements
ok      gitea.urkob.com/urko/git-webhook-ci/internal/watcher    2.024s  coverage: 80.0% of statements
coverage: 100.0% of statements
ok      gitea.urkob.com/urko/git-webhook-ci/pkg/watcher 0.017s  coverage: 100.0% of statements

goreportcard

➜  git-webhook-ci git:(main) ✗ make goreportcard 
oreportcard-cli -v
Grade .......... A+ 100.0%
Files .................. 6
Issues ................. 0
gofmt ............... 100%
go_vet .............. 100%
gocyclo ............. 100%
ineffassign ......... 100%
license ............. 100%
misspell ............ 100%