Simple cross platform service to run a command when triggered by a GitHub webhook. Built in C# using .NET Native to support Windows, Linux and OSX.
You can download a native binary of the latest release or you can use the Docker container.
The service binds to localhost:5000 by default, to bind to a different address use the --server.urls flag, e.g. ghd --server.urls=http://0.0.0.0:80.
All configuration options are stored in settings.json. Multiple repositories and branches can be watched by creating multiple profiles.
If you disable SSH then the deploy command will run locally under the user which launched the service.
"SSH": {
"Enabled": false
}
"SSH": {
"Enabled": true,
"Host": "192.168.0.1",
"Port": 22,
"Username": "root",
"Password": "qwerty"
}
"SSH": {
"Enabled": true,
"Host": "192.168.0.1",
"Port": 22,
"Username": "root",
"KeyFile": "/root/.ssh/id_rsa",
"KeyPassword": null // or "qwerty"
}
The GitHub configuration is simply the repository and branch to accept webhooks from.
"GitHub": {
"Repository": "githubtraining/hellogitworld",
"Branch": "master"
}
The deploy section specifies the command to run either locally or over SSH.
Both the Command and Arguments strings are interpolated with the data from the GitHub webhook, exposing the full objects.
"Deploy": {
"Command": "bash",
"Arguments": "-c \"echo Deploying {Repository.FullName} [{HeadCommit.Timestamp}]: {HeadCommit.Message}\""
}
"Deploy": {
"Command": "cmd",
"Arguments": "/C echo Deploying {Repository.FullName} [{HeadCommit.Timestamp}]: {HeadCommit.Message}"
}
Once the service is running, add a new webhook to your GitHub repository:
Payload URL: The service will accept any URL that resolves to it
Content type: application/json
Secret: Ignored
Event: Only the push event is currently used
If you have .NET Core installed then just run dotnet run -c Release to start the service directly.
To build a portable native binary run dotnet publish -c Release -r centos.7-x64 replacing the runtime flag with your target platform. The app will be built in bin/Release/netcoreapp1.0/<runtime>/publish. See project.json for supported runtimes.
Alternatively you can run and build the service under Docker with the provided Compose file.
Content type
Image
Digest
Size
118.9 MB
Last updated
over 9 years ago
docker pull joebiellik/ghd