Sign inSign up

joebiellik/ghd

By joebiellik

Updated over 9 years ago

GitHub Deploy automated build

Image
0

451

joebiellik/ghd repository overview

GitHub Deploy

License Release Version Dependency Status Build Status Docker Build Docker Pulls

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.

Running

You can download a native binary of the latest release or you can use the Docker container.

Configuration

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.

SSH
Disabled

If you disable SSH then the deploy command will run locally under the user which launched the service.

"SSH": {
  "Enabled": false
}
Password
"SSH": {
  "Enabled": true,
  "Host": "192.168.0.1",
  "Port": 22,
  "Username": "root",
  "Password": "qwerty"
}
Public Key
"SSH": {
  "Enabled": true,
  "Host": "192.168.0.1",
  "Port": 22,
  "Username": "root",
  "KeyFile": "/root/.ssh/id_rsa",
  "KeyPassword": null // or "qwerty"
}
GitHub

The GitHub configuration is simply the repository and branch to accept webhooks from.

"GitHub": {
  "Repository": "githubtraining/hellogitworld",
  "Branch": "master"
}
Deploy

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.

Linux example
"Deploy": {
  "Command": "bash",
  "Arguments": "-c \"echo Deploying {Repository.FullName} [{HeadCommit.Timestamp}]: {HeadCommit.Message}\""
}
Windows example
"Deploy": {
  "Command": "cmd",
  "Arguments": "/C echo Deploying {Repository.FullName} [{HeadCommit.Timestamp}]: {HeadCommit.Message}"
}

Setup

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

Building

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.

Tag summary

Content type

Image

Digest

Size

118.9 MB

Last updated

over 9 years ago

docker pull joebiellik/ghd