Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
changelog:
exclude:
labels:
- ignore-for-release
authors:
- github-actions
categories:
- title: New Features
labels:
- feature
- enhancement
- feat
- title: Bug Fixes
labels:
- bug
- fix
- title: Documentation
labels:
- documentation
- docs
- title: Maintenance
labels:
- chore
- dependencies
- refactor
- title: Other Changes
labels:
- "*"
140 changes: 140 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: release

on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Release version, for example v2.8.4"
required: true
type: string

permissions:
contents: write

jobs:
test:
env:
GOTOOLCHAIN: local
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.x"
- name: Test
run: go test -v ./...

build:
env:
CGO_ENABLED: "0"
GOTOOLCHAIN: local
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: freebsd
goarch: 386
- goos: freebsd
goarch: amd64
- goos: freebsd
goarch: arm64
- goos: linux
goarch: 386
- goos: linux
goarch: amd64
- goos: linux
goarch: arm
- goos: linux
goarch: arm64
- goos: openbsd
goarch: 386
- goos: openbsd
goarch: amd64
- goos: openbsd
goarch: arm64
- goos: windows
goarch: 386
- goos: windows
goarch: amd64
- goos: windows
goarch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.x"

- name: Resolve version
id: version
shell: bash
run: |
version="${{ github.event.inputs.version || github.ref_name }}"
version="${version#v}"
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Build archive
shell: bash
run: |
target="webhook-${{ matrix.goos }}-${{ matrix.goarch }}"
mkdir -p "dist/$target"

binary="webhook"
if [ "${{ matrix.goos }}" = "windows" ]; then
binary="webhook.exe"
fi

GOOS="${{ matrix.goos }}" GOARCH="${{ matrix.goarch }}" \
go build -trimpath -ldflags="-s -w -X main.version=${{ steps.version.outputs.version }}" \
-o "dist/$target/$binary" .

cp LICENSE README.md "dist/$target/"
tar -czf "dist/$target.tar.gz" -C dist "$target"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: webhook-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/*.tar.gz
if-no-files-found: error

publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- name: Generate checksums
shell: bash
run: |
cd dist
sha256sum *.tar.gz > checksums.txt

- name: Resolve tag
id: tag
shell: bash
run: |
tag="${{ github.event.inputs.version || github.ref_name }}"
echo "tag=$tag" >> "$GITHUB_OUTPUT"

- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: ${{ steps.tag.outputs.tag }}
files: |
dist/*.tar.gz
dist/checksums.txt
generate_release_notes: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ coverage
webhook
/test/hookecho
build

.gocache/
.DS_Store
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

<img src="https://github.com/adnanh/webhook/raw/development/docs/logo/logo-128x128.png" alt="Webhook" align="left" />

[webhook][w] 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][w] also allows you to specify rules which have to be satisfied in order for the hook to be triggered.
[webhook][w] 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][w] also allows you to specify rules which have to be satisfied in order for the hook to be triggered.

Chinese documentation with the fork-specific install, Admin UI, release, and operations guide is available in [中文说明](README_CN.md).

For example, if you're using Github or Bitbucket, you can use [webhook][w] 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.

Expand Down Expand Up @@ -46,7 +48,22 @@ If you are using Debian linux ("stretch" or later), you can install webhook usin
If you are using FreeBSD, you can install webhook using `pkg install webhook`.

### Download prebuilt binaries
Prebuilt binaries for different architectures are available at [GitHub Releases](https://github.com/adnanh/webhook/releases).
Prebuilt binaries for different architectures are available at [GitHub Releases](https://github.com/xtulnx/webhook/releases).

### One-line install or update
The install scripts download the latest GitHub Release asset for your platform and replace the local binary.

Linux, macOS, FreeBSD, or OpenBSD:
```bash
curl -fsSL https://raw.githubusercontent.com/xtulnx/webhook/master/scripts/install.sh | sh
```

Windows PowerShell:
```powershell
irm https://raw.githubusercontent.com/xtulnx/webhook/master/scripts/install.ps1 | iex
```

Set `WEBHOOK_VERSION` to install a specific release tag, `WEBHOOK_REPO` to install from a fork, or `WEBHOOK_INSTALL_DIR` to choose the destination directory.

## Configuration
Next step is to define some hooks you want [webhook][w] to serve.
Expand Down Expand Up @@ -101,6 +118,8 @@ All files are ignored unless they match one of the following criteria:

In either case, the given file part will be parsed as JSON and added to the `payload` map.

If you want a hook command to inspect uploaded files directly, enable the `keep-file-environment` hook option. During command execution webhook will expose each uploaded file as `HOOK_FILE_<FIELD>` and the original filename as `HOOK_FILENAME_<FIELD>`, then remove the temporary file once the command exits. Because multipart field names are copied into the environment variable name after uppercasing, prefer names made of letters, numbers, and underscores if the command will read them from a shell script.

## Templates
[webhook][w] can parse the hooks configuration file as a Go template when given the `-template` [CLI parameter](docs/Webhook-Parameters.md). See the [Templates page](docs/Templates.md) for more details on template usage.

Expand Down
Loading