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
2024-07-14 23:08:29 +00:00
/path/to/gh-wh-handler.< arch > /path/to/config.json
2024-07-14 21:32:17 +00:00
```
You can see the config file format below.
2024-07-18 00:43:54 +00:00
### Install from source
2024-07-14 21:32:17 +00:00
2024-07-18 00:43:54 +00:00
#### Install the dependencies:
2023-12-30 16:19:05 +00:00
- [CrowCpp ](https://crowcpp.org/master/ )
- [nlohmann::json ](https://github.com/nlohmann/json )
2024-07-18 00:43:54 +00:00
#### Build the application:
1. Clone the repository:
2023-12-30 12:06:34 +00:00
```console
2024-07-18 00:43:54 +00:00
git clone https://github.com/TiagoRG/gh-wh-handler.git
2023-12-30 12:06:34 +00:00
```
2024-07-18 00:43:54 +00:00
2. Create the build directory:
```console
cd gh-wh-handler
mkdir build
cd build
```
3. Run CMake:
```console
cmake ..
```
4. Build and install the application:
```console
sudo make install
```
#### Run the application:
The application is running on a systemd service, which is both enabled and started after installation.
You can start, stop, restart, and check the status of the service using the following commands:
2023-12-30 12:06:34 +00:00
```console
2024-07-18 00:43:54 +00:00
sudo systemctl start gh-wh-handler # Start the service
sudo systemctl stop gh-wh-handler # Stop the service
sudo systemctl restart gh-wh-handler # Restart the service
sudo systemctl status gh-wh-handler # Check the status of the service
2023-12-30 12:06:34 +00:00
```
2024-07-18 00:43:54 +00:00
You can also check the logs of the service using the following command:
```console
journalctl -u gh-wh-handler
```
## Configuration
As of now, the configuration menu is not yet implemented so you have to create the configuration file manually.
2024-02-21 12:09:59 +00:00
2024-07-18 00:43:54 +00:00
### Config File
2023-12-30 12:06:34 +00:00
2024-07-18 00:43:54 +00:00
The configuration file can be found in `/services/gh-wh-handler/config.json` and has the following format:
2023-12-30 12:06:34 +00:00
```json
{
2024-07-18 00:43:54 +00:00
"port": 65001,
"update-files": {
"owner/repo-name": {
"branch": "main",
"files": {
"path/to/remote/file": "/path/to/local/file",
"...": "..."
},
"post-update": [
"post-update-command",
"post-update-script",
"..."
]
2023-12-30 12:06:34 +00:00
}
2024-07-18 00:43:54 +00:00
},
"run-scripts": {
"owner/repo-name": {
"branch": "main",
"actions": [
"command",
"script",
]
}
},
"tokens": {
"owner/repo-name": "token"
}
2023-12-30 12:06:34 +00:00
}
```
2023-12-30 21:01:25 +00:00
2024-07-18 00:43:54 +00:00
## Endpoints
Currently, the only endpoint for the application is `/update-files` , which is used to update the local files on every push as well as run post-update scripts.
Since only the `/update-files` endpoint is implemented, the configuration file may not contain the `run-scripts` field.
## License
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE ](LICENSE ) file for details.
2023-12-30 21:01:25 +00:00