2023-12-30 11:59:45 +00:00
|
|
|
# GitHub Webhook Handler
|
2023-12-30 12:06:34 +00:00
|
|
|
|
|
|
|
## Simple C++ WebAPI to work with GitHub Webhooks
|
|
|
|
|
|
|
|
Currently creating a local copy of remote files on every push
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2024-07-14 21:32:17 +00:00
|
|
|
### Run prebuilt binary
|
|
|
|
|
|
|
|
Head over to the [Releases Page](https://github.com/TiagoRG/gh-wh-handler/releases) and download the desired binary.
|
|
|
|
|
|
|
|
Run the application using your configuration file:
|
|
|
|
```console
|
|
|
|
/path/to/gh_wh_handler_<arch> /path/to/config.json
|
|
|
|
```
|
|
|
|
|
|
|
|
You can see the config file format below.
|
|
|
|
|
|
|
|
### Run from source
|
|
|
|
|
2023-12-30 16:19:05 +00:00
|
|
|
Install the dependencies:
|
|
|
|
|
|
|
|
- [CrowCpp](https://crowcpp.org/master/)
|
|
|
|
- [nlohmann::json](https://github.com/nlohmann/json)
|
|
|
|
|
2023-12-30 12:06:34 +00:00
|
|
|
Compile the application:
|
|
|
|
```console
|
|
|
|
make
|
|
|
|
```
|
|
|
|
|
|
|
|
Run the application using your configuration file:
|
|
|
|
```console
|
2024-07-14 21:32:17 +00:00
|
|
|
bin/gh_wh_handler /path/to/config.json
|
2023-12-30 12:06:34 +00:00
|
|
|
```
|
|
|
|
|
2024-02-21 12:09:59 +00:00
|
|
|
Note: default config file path is `/etc/gh_wh_handler/config.json`
|
|
|
|
|
2023-12-30 12:06:34 +00:00
|
|
|
## Config File
|
|
|
|
|
|
|
|
The configuration file should be a JSON file with the following format:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"port": 8080,
|
|
|
|
"repos": {
|
|
|
|
"repo_full_name": {
|
|
|
|
"branch": "target_branch",
|
|
|
|
"files": {
|
2024-01-27 16:33:12 +00:00
|
|
|
"remote_path": "local_path"
|
2023-12-30 12:06:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"tokens": {
|
|
|
|
"repo_full_name": "github_token"
|
2024-02-21 12:09:59 +00:00
|
|
|
},
|
|
|
|
"actions": {
|
|
|
|
"repo_full_name": [
|
|
|
|
"command1",
|
|
|
|
"command2"
|
|
|
|
]
|
2023-12-30 12:06:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
2023-12-30 21:01:25 +00:00
|
|
|
|
|
|
|
## Endpoint
|
|
|
|
|
2024-01-27 16:33:12 +00:00
|
|
|
Currently, the only endpoint for the application is /update-files
|