Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN make test

RUN make build

FROM ubuntu:24.04
FROM debian:bookworm-slim

ENV DEBIAN_FRONTEND=noninteractive

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ test:
@go test -v $(SRC)

lint: ## Run linter
@golangci-lint run
@golangci-lint run -v\
--config=./.golangci.yaml\
--timeout=5m\
--out-format=colored-line-number

fmt: ## Format golang source files
@go fmt ./...
Expand Down
89 changes: 81 additions & 8 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,103 @@

## Deploying the service

The service can be deployed in your choice of infrastructure
The service can be deployed in your choice of infrastructure. To allow webhooks to be pushed to `promgithub` make sure your service deployment is accessible from your Github instance.

### Service Parameters

The service expects the following parameters to be set:

- **Environment Variables**:
- `PROMGITHUB_WEBHOOK_SECRET`: The secret used to validate incoming GitHub webhook requests.
- `PROMGITHUB_SERVICE_PORT` (optional): Service API port (default is `8080`).

### Deploying in kubernetes

To deploy the service in a kubernetes cluster you can use the provided helm chart.

**TODO:** Add helm chart details

When deploying with kubernetes add the following resources to your `promgithub` deployment

### Kubernetes deployment requirements

Add the helm repo as a dependency to your chart deployment:

```yaml
apiVersion: v2
name: promgithub
description: Deployment of promgithub
type: application
version: <chart version>

dependencies:
- name: promgithub
version: "<promgithub-charts version>"
repository: "oci://ghcr.io/darthfork/promgithub-charts"
```

#### Resources

- **Ingress**: Ingress allowing github to access `promgithub` deployment

#### Chart and Values

Create a values file with the webhook-secret and (optional) service-port values for your chart

```yaml
promgithub:
webhook-secret: <your webhook secret>
service-port: <service port>
```

## Deploying service in a container

To deploy the service in a container using a container management environment like fargate/docker-compose, you can use the `promgithub` container from the [GHCR container repository](https://github.com/darthfork/promgithub/pkgs/container/promgithub)

## Deploying service binary
#### Docker CLI

The service binaries are also available under [github releases](https://github.com/darthfork/promgithub/releases) which can be deployed as the user wishes.
Run the service using docker cli as follows:

```bash
docker run\
-e PROMGITHUB_WEBHOOK_SECRET=<your webhook secret>\
-e PROMGITHUB_SERVICE_PORT=<service port>\
-p <HOST_PORT>:<CONTAINER_PORT>
ghcr.io/darthfork/promgithub:<version>
```

### Service Parameters
#### Docker Compose

The service expects the following parameters to be set:
To run the service in docker compose, create a compose file as below:

- **Environment Variables**:
- `PROMGITHUB_WEBHOOK_SECRET`: The secret used to validate incoming GitHub webhook requests.
- `PROMGITHUB_SERVICE_PORT` (optional): Service API port (default is `8080`).
```yaml
# promgithub-compose.yaml
services:
promgithub:
image: ghcr.io/darthfork/promgithub:<version>
hostname: promgithub
stdin_open: false
tty: false
environment:
- PROMGITHUB_WEBHOOK_SECRET=<your webhook secret>
- PROMGITHUB_SERVICE_PORT=<service port (optional)>
ports:
- <HOST_PORT>:<CONTAINER_PORT>
```

To start the `promgithub` container with compose run:

```bash
docker-compose -f promgithub-compose.yaml run --rm promgithub
```

## Deploying service binary

The service binaries are also available under [github releases](https://github.com/darthfork/promgithub/releases) which can be deployed as the user wishes.

```bash
PROMGITHUB_WEBHOOK_SECRET="<your webhook secret>" PROMGITHUB_SERVICE_PORT="<service port>" /path/to/binary/promgithub
```

## Setting up the Webhook in GitHub (Repository/Organization)

Expand Down
18 changes: 9 additions & 9 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ func APIHandler(logger *zap.Logger) func(http.Handler) http.Handler {
}
}

func healthCheck(w http.ResponseWriter, r *http.Request) {
response := HealthCheckResposne{Status: "ok", Version: Version}
err := json.NewEncoder(w).Encode(response)
if err != nil {
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
return
}
}

func init() {
var err error
loggerConfig := zap.NewProductionConfig()
Expand All @@ -99,15 +108,6 @@ func init() {
defer logger.Sync()
}

func healthCheck(w http.ResponseWriter, r *http.Request) {
response := HealthCheckResposne{Status: "ok", Version: Version}
err := json.NewEncoder(w).Encode(response)
if err != nil {
http.Error(w, "Failed to encode response", http.StatusInternalServerError)
return
}
}

func main() {
port := strings.TrimSpace(os.Getenv("PROMGITHUB_SERVICE_PORT"))
if port == "" {
Expand Down