README ci to download

This commit is contained in:
Martin/Geno 2019-02-14 05:05:03 +01:00
parent d9061412e5
commit e4128593c4
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
5 changed files with 46 additions and 12 deletions

View File

@ -13,9 +13,10 @@ build-my-project:
stage: build
script:
- go install dev.sum7.eu/$CI_PROJECT_PATH
- mv /go/bin/$CI_PROJECT_NAME /builds/$CI_PROJECT_PATH
artifacts:
paths:
- /go/bin/$CI_PROJECT_NAME
- $CI_PROJECT_NAME
test-my-project:
stage: test

View File

@ -3,3 +3,45 @@
[![Go Report Card](https://goreportcard.com/badge/dev.sum7.eu/genofire/hook2xmpp)](https://goreportcard.com/report/dev.sum7.eu/genofire/hook2xmpp)
[![GoDoc](https://godoc.org/dev.sum7.eu/genofire/hook2xmpp?status.svg)](https://godoc.org/dev.sum7.eu/genofire/hook2xmpp)
## Get hook2xmpp
#### Download
Latest Build binary from ci here:
[Download](https://dev.sum7.eu/genofire/hook2xmpp/-/jobs/artifacts/master/raw/hook2xmpp?inline=false&job=compile)
#### Build
```bash
go get -u dev.sum7.eu/genofire/hook2xmpp
```
## Configure
see `config_example.conf`
## Start / Boot
_/lib/systemd/system/hook2xmpp.service_ :
```
[Unit]
Description=hook2xmpp
After=network.target
# After=ejabberd.service
# After=prosody.service
[Service]
Type=simple
# User=notRoot
ExecStart=/opt/go/bin/hook2xmpp --config /etc/hook2xmpp.conf
Restart=always
RestartSec=5sec
[Install]
WantedBy=multi-user.target
```
Start: `systemctl start hook2xmpp`
Autostart: `systemctl enable hook2xmpp`

View File

@ -8,7 +8,6 @@ import (
libHTTP "dev.sum7.eu/genofire/golang-lib/http"
"github.com/bdlm/log"
xmpp "github.com/mattn/go-xmpp"
"github.com/mitchellh/mapstructure"
"dev.sum7.eu/genofire/hook2xmpp/runtime"
)
@ -36,11 +35,8 @@ func init() {
return func(w http.ResponseWriter, r *http.Request) {
logger := log.WithField("type", hookType)
var body interface{}
libHTTP.Read(r, &body)
var request requestBody
if err := mapstructure.Decode(body, &request); err != nil {
if err := libHTTP.Read(r, &request); err != nil {
logger.Errorf("no readable payload: %s", err)
http.Error(w, fmt.Sprintf("no readable payload"), http.StatusInternalServerError)
return

View File

@ -16,7 +16,6 @@ import (
var eventHeader = map[string]string{
"X-GitHub-Event": "X-Hub-Signature",
"X-Gogs-Event": "X-Gogs-Delivery",
"X-Gitlab-Event": "X-Gitlab-Token",
}
const hookType = "git"

View File

@ -7,7 +7,6 @@ import (
libHTTP "dev.sum7.eu/genofire/golang-lib/http"
"github.com/bdlm/log"
xmpp "github.com/mattn/go-xmpp"
"github.com/mitchellh/mapstructure"
"dev.sum7.eu/genofire/hook2xmpp/runtime"
)
@ -53,11 +52,8 @@ func init() {
return
}
var body interface{}
libHTTP.Read(r, &body)
var request requestBody
if err := mapstructure.Decode(body, &request); err != nil {
if err := libHTTP.Read(r, &request); err != nil {
logger.Errorf("no readable payload: %s", err)
http.Error(w, fmt.Sprintf("no readable payload"), http.StatusInternalServerError)
return