Update README.md

Signed-off-by: Tiago Garcia <tiago.rgarcia@ua.pt>
This commit is contained in:
Tiago Garcia 2024-07-18 01:43:54 +01:00
parent 11f0a82b23
commit 2409ec8f5a
Signed by: TiagoRG
GPG Key ID: DFCD48E3F420DB42
1 changed files with 81 additions and 29 deletions

110
README.md
View File

@ -17,53 +17,105 @@ Run the application using your configuration file:
You can see the config file format below.
### Run from source
### Install from source
Install the dependencies:
#### Install the dependencies:
- [CrowCpp](https://crowcpp.org/master/)
- [nlohmann::json](https://github.com/nlohmann/json)
Build the application:
#### Build the application:
1. Clone the repository:
```console
cmake -S . -B build
cmake --build build
git clone https://github.com/TiagoRG/gh-wh-handler.git
```
Run the application using your configuration file:
2. Create the build directory:
```console
bin/gh-wh-handler.<arch> /path/to/config.json
cd gh-wh-handler
mkdir build
cd build
```
Note: default config file path is `/etc/gh-wh-handler/config.json`
3. Run CMake:
```console
cmake ..
```
## Config File
4. Build and install the application:
```console
sudo make install
```
The configuration file should be a JSON file with the following format:
#### 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:
```console
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
```
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.
### Config File
The configuration file can be found in `/services/gh-wh-handler/config.json` and has the following format:
```json
{
"port": 8080,
"repos": {
"repo_full_name": {
"branch": "target_branch",
"files": {
"remote_path": "local_path"
}
}
},
"tokens": {
"repo_full_name": "github_token"
},
"actions": {
"repo_full_name": [
"command1",
"command2"
]
"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",
"..."
]
}
},
"run-scripts": {
"owner/repo-name": {
"branch": "main",
"actions": [
"command",
"script",
]
}
},
"tokens": {
"owner/repo-name": "token"
}
}
```
## Endpoint
## 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.
Currently, the only endpoint for the application is `/update-files`