mirror of
https://codeberg.org/Mo8it/git-webhook-client
synced 2024-11-21 11:06:32 +00:00
Update documentation
This commit is contained in:
parent
d53793e77b
commit
730e0e2def
5 changed files with 90 additions and 51 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,7 +1,6 @@
|
|||
/Cargo.lock
|
||||
config.yaml
|
||||
/dev_data/
|
||||
*.json
|
||||
*.log
|
||||
/scripts/
|
||||
/target/
|
||||
*.yaml
|
||||
|
|
|
@ -16,9 +16,6 @@ RUN cargo build --release --bin git-webhook-client
|
|||
|
||||
FROM docker.io/library/debian:stable-slim AS runtime
|
||||
WORKDIR app
|
||||
ARG data_dir=/volumes/data
|
||||
ENV DATABASE_URL=$data_dir/db/db.sqlite
|
||||
ENV GWC_CONFIG_FILE=$data_dir/config.yaml
|
||||
RUN apt update && \
|
||||
apt install libsqlite3-dev -y
|
||||
COPY --from=builder /app/target/release/git-webhook-client /usr/local/bin/git-webhook-client
|
||||
|
|
63
README.md
63
README.md
|
@ -9,70 +9,41 @@ Currently, only Gitea is supported. If you want support for Gitlab or Github, th
|
|||
- Verify the webhook event with a secret.
|
||||
- Run a configured command to a specific repository on a webhook event.
|
||||
- Save the output of the command.
|
||||
- Show an output by visiting the url of the client.
|
||||
- Supported configuration for multiple repositories.
|
||||
- Show an output by visiting its URL.
|
||||
- Send email after a webhook trigger.
|
||||
- Support configuration for multiple repositories.
|
||||
- Written in Rust :D
|
||||
|
||||
## Getting started
|
||||
|
||||
### Requirements
|
||||
|
||||
- `cargo` to compile the source code.
|
||||
- Development package for SQLite (`sqlite-devel` on Fedora)
|
||||
First, clone the repository and create the configuration file (see below).
|
||||
|
||||
### Configuration
|
||||
|
||||
The program looks for the configuration file configured with the environment variable `GWC_CONFIG_FILE` that contains the following:
|
||||
The program looks for the configuration file set with the environment variable `GWC_CONFIG_FILE`.
|
||||
|
||||
<!-- TODO: Adjust to new config -->
|
||||
Use the commented template configuration file `template_config.yaml` as a starting point.
|
||||
|
||||
1. `secret`: The secret of the webhook.
|
||||
1. `base_url`: The base_url of the webhook client.
|
||||
1. `hooks`: List of webhooks.
|
||||
1. `clone_url`: Repository url.
|
||||
1. `current_dir`: The directory to run the command in.
|
||||
1. `command`: The command without any arguments.
|
||||
1. `args`: List of arguments separated by a comma.
|
||||
### Running
|
||||
|
||||
#### Example configuration file:
|
||||
#### Containerized
|
||||
|
||||
<!-- TODO: Adjust to new config -->
|
||||
With Docker or Podman, use the compose file `compose.yaml` as a starting point.
|
||||
|
||||
```yaml
|
||||
secret: CHANGE_ME!
|
||||
base_url: https://webhook.mo8it.com
|
||||
#### Not containerized
|
||||
|
||||
hooks:
|
||||
clone_url: https://codeberg.org/Mo8it/git-webhook-client
|
||||
current_dir: .
|
||||
command: ls
|
||||
args: ["-l", "-a", "test_directory"]
|
||||
```
|
||||
Requirements:
|
||||
|
||||
#### First setup
|
||||
- `cargo` to compile the source code.
|
||||
- Development package for SQLite (`sqlite-devel` on Fedora, `libsqlite3-dev` on Debian)
|
||||
|
||||
<!-- TODO: Auto migration -->
|
||||
Run the command `cargo install --path .` to compile.
|
||||
|
||||
- Clone the repository.
|
||||
- Create the configuration file.
|
||||
- Run the following to initialize the database:
|
||||
```bash
|
||||
cargo install diesel_cli --no-default-features --features sqlite
|
||||
DATABASE_URL=PATH/TO/DATABASE/DIRECTORY/db.sqlite diesel_cli migration run
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
#### Run
|
||||
|
||||
After running `cargo build --release`, the binary can be found in the directory `target/release/git-webhook-client`. To run it, you have to specify the environment variable `DATABASE_URL`:
|
||||
|
||||
```bash
|
||||
DATABASE_URL=PATH/TO/DATABASE/DIRECTORY/db.sqlite target/release/git-webhook-client
|
||||
```
|
||||
Run the command `GWC_CONFIG_FILE=/path/to/config.yaml ~/.cargo/bin/git-webhook-client` to start the client.
|
||||
|
||||
#### Setup on the git server
|
||||
|
||||
Setup the webhook for the configured repositories on the git server. Don't forget to enter the same secret that you did specify in the configuration file.
|
||||
Setup the webhook for the configured repositories on the git server. Don't forget to enter the same secret that you did specify in the YAML configuration file.
|
||||
|
||||
#### Show output
|
||||
|
||||
|
@ -80,7 +51,7 @@ After an event, the client responds with a URL that shows the log. The id in tha
|
|||
|
||||
If you want to see the last log, just visit the `base_url` from the configuration.
|
||||
|
||||
To see a specific log with an id, visit the URL: `base_url/?id=THE_ID_OF_AN_EVENT`.
|
||||
To see a specific log with an id, visit the URL: `base_url/?id=THE_ID_OF_THE_EVENT`.
|
||||
|
||||
You can specify a negative ID to see the last events. `id=-1` corresponds to the last log, `id=-2` corresponds to the log before it and so on.
|
||||
|
||||
|
|
13
compose.yaml
Normal file
13
compose.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
|
||||
services:
|
||||
gwc:
|
||||
container_name: git-webhook-client
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Containerfile
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data:/volumes/data:Z
|
||||
environment:
|
||||
- GWC_CONFIG_FILE=/volumes/data/config.yaml
|
59
template_config.yaml
Normal file
59
template_config.yaml
Normal file
|
@ -0,0 +1,59 @@
|
|||
---
|
||||
|
||||
# The secret of the webhook
|
||||
secret: CHANGE_ME!
|
||||
|
||||
# The base URL of the webhook client
|
||||
base_url: https://webhook.mo8it.com
|
||||
|
||||
# SQLite database path
|
||||
sqlite_db_path: /path/to/db.sqlite
|
||||
|
||||
socket_address:
|
||||
# IP address to bind to.
|
||||
# Change to [127, 0, 0, 1] if you want to run the client locally.
|
||||
address: [0, 0, 0, 0]
|
||||
# Port to bind to
|
||||
port: 8080
|
||||
|
||||
# Email server connection
|
||||
email_server:
|
||||
server_name: posteo.de
|
||||
email: change_me@posteo.net
|
||||
password: EMAIL_PASSWORD
|
||||
|
||||
# Email FROM <Webhook change_me@posteo.net>
|
||||
email_from:
|
||||
name: Webhook
|
||||
user: change_me
|
||||
domain: posteo.net
|
||||
|
||||
# Email TO <Me me@proton.me>
|
||||
email_to:
|
||||
name: Me
|
||||
user: me
|
||||
domain: proton.me
|
||||
|
||||
logging:
|
||||
# Log file directory
|
||||
directory: /path/to/log/dir
|
||||
# Log file name
|
||||
filename: log.txt
|
||||
|
||||
# List of webhooks
|
||||
hooks:
|
||||
- # Name shown in email subject
|
||||
name: GWC
|
||||
# Repository clone URL
|
||||
clone_url: https://codeberg.org/Mo8it/git-webhook-client.git
|
||||
# The directory to run the command in
|
||||
current_dir: /volumes/scripts
|
||||
# The command to run without any args
|
||||
command: ls
|
||||
# List of args for the command
|
||||
args: ["-l", "-a", "old_scripts"]
|
||||
- name: AdvLabDB
|
||||
clone_url: https://codeberg.org/Mo8it/advlabdb.git
|
||||
current_dir: /volumes/advlabdb/scripts
|
||||
command: ./backup.sh
|
||||
args: []
|
Loading…
Reference in a new issue