Golang 跨平台的 Webhook

栏目: Go · 发布时间: 7年前

内容简介:简单几步就能部署运行起来的Webhook.wget

文章原创首发地址

简单几步就能部署运行起来的Webhook.

获取webhook

wget https://github.com/adnanh/webhook/releases/download/2.6.8/webhook-linux-amd64.tar.gz

解压缩

tar -zxvf ./webhook-linux-amd64.tar.gz

添加配置文件

webhook.json update-qd1024.sh

其中webhook.json 是配置webhook id 等信息,由于过于简单且自解释,就不详解了,有问题的可以给我留言。

[
  {
    "id": "webhook_update_qd1024",
    "execute-command": "update-qd1024.sh",
    "command-working-directory": "/home",
  }
]

update-qd1024.sh 就是具体执行命令的脚本了,从中可以看出和gogs的配合。

#!/bin/bash

cd /home/docker/gogs/www/qd1024
git --work-tree=/home/docker/gogs/www/qd1024 --git-dir=/home/docker/gogs/git/gogs-repositories/xin/qd1024.git checkout -f > git.log 
/home/hugo >hugo_qd1024.log

运行

写好配置文件,就是要跑起来。

后台运行webhook

nohup /home/webhook/webhook -port 10100 -hotreload -hooks /home/webhook/webhook.json -verbose > webhook.log 2>&1 &

验证

在gogo后台添加webhook,并测试运行。

官方简介

webhook is a lightweight configurable tool written in Go, that allows you to easily create HTTP endpoints (hooks) on your server, which you can use to execute configured commands. You can also pass data from the HTTP request (such as headers, payload or query variables) to your commands. webhook also allows you to specify rules which have to be satisfied in order for the hook to be triggered.

For example, if you're using Github or Bitbucket, you can use webhook to set up a hook that runs a redeploy script for your project on your staging server, whenever you push changes to the master branch of your project.

If you use Mattermost or Slack, you can set up an "Outgoing webhook integration" or "Slash command" to run various commands on your server, which can then report back directly to you or your channels using the "Incoming webhook integrations", or the appropriate response body.

webhook aims to do nothing more than it should do, and that is:

receive the request,

parse the headers, payload and query variables,

check if the specified rules for the hook are satisfied,

and finally, pass the specified arguments to the specified command via command line arguments or via environment variables.

Everything else is the responsibility of the command's author.

下载地址

github

项目主页

github

以上所述就是小编给大家介绍的《Golang 跨平台的 Webhook》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

浅薄

浅薄

[美] 尼古拉斯·卡尔 / 刘纯毅 / 中信出版社 / 2010-12 / 42.00元

《浅薄:互联网如何毒化了我们的大脑》在我们跟计算机越来越密不可分的过程中,我们越来越多的人生体验通过电脑屏幕上闪烁摇曳、虚无缥缈的符号完成,最大的危险就是我们即将开始丧失我们的人性,牺牲人之所以区别于机器的本质属性。——尼古拉斯•卡尔“谷歌在把我们变傻吗?”当尼古拉斯•卡尔在发表于《大西洋月刊》上赫赫有名的那篇封面文章中提出这个问题的时候,他就开启了人们热切渴望的期盼源泉,让人急于弄清楚互联网是在......一起来看看 《浅薄》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

SHA 加密
SHA 加密

SHA 加密工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具