The GitHub Actions Exporter is a service designed to collect and expose metrics about GitHub Actions workflows for monitoring with Prometheus.
- Go 1.21 or newer
- Docker (optional, for containerization)
-
Clone the repository:
git clone https://github.com/Replaid-inc/github-actions-exporter.git cd github-actions-exporter -
Install dependencies:
go mod tidy
-
Build the application:
go build -o github-actions-exporter cmd/gh-actions-exporter/main.go
The application can be configured using environment variables:
| Variable | Description | Default | Required |
|---|---|---|---|
PORT |
The port the server will listen on | :8080 |
No |
GITHUB_WEBHOOK_SECRET |
Secret token for verifying GitHub webhook signatures | None | Recommended for production |
To set up GitHub webhooks for your repositories:
- Go to your repository's Settings > Webhooks
- Click "Add webhook"
- Set the Payload URL to
https://your-domain.com/webhook - Set Content type to
application/json - Select "Let me select individual events" and choose:
- Workflow runs
- Workflow jobs (optional)
- Add your webhook secret (should match
GITHUB_WEBHOOK_SECRET) - Click "Add webhook"
PORT: The port the server will listen on (default::8080)GITHUB_WEBHOOK_SECRET: The secret token for verifying GitHub webhook signatures (optional but recommended for production)
To run the application, execute the following command:
# Run directly with Go
go run cmd/gh-actions-exporter/main.go
# Or run the built binary
./github-actions-exporterYou can also run the application using Docker:
# Build the Docker image
docker build -t github-actions-exporter .
# Run the container
docker run -p 8080:8080 \
-e GITHUB_WEBHOOK_SECRET=your-secret \
github-actions-exporterDeploy to Kubernetes using the provided Helm chart:
# Add the repository (replace with your actual Helm repository)
helm repo add github-actions-exporter https://Replaid-inc.github.io/github-actions-exporter
# Install the chart
helm install github-actions-exporter github-actions-exporter/github-actions-exporter \
--set image.repository=your-registry/github-actions-exporter \
--set image.tag=latest \
--set env.GITHUB_WEBHOOK_SECRET=your-webhook-secretThe application will start an HTTP server that listens for GitHub webhook events at /webhook and exposes Prometheus metrics at /metrics.
When GITHUB_WEBHOOK_SECRET is set, the application will verify the HMAC signature of incoming webhooks using the X-Hub-Signature-256 header. This ensures that webhooks are genuinely from GitHub and haven't been tampered with.
If no secret is configured, signature verification is skipped (not recommended for production use).
Status of GitHub workflow runs with the following labels:
repository: The repository full name (e.g., "owner/repo")workflow: The name of the workflowbranch: The branch name or tag nametrigger: The event that triggered the workflow (e.g., "push", "pull_request", "schedule", etc.)ref_type: Indicates whether the workflow was triggered by a "branch" or a "tag"
Values:
- 0 = timed_out
- 1 = failure
- 2 = startup_failure
- 3 = cancelled
- 4 = skipped
- 5 = neutral
- 6 = stale
- 7 = null
- 8 = action_required
- 9 = in_progress
- 10 = success
Example Prometheus queries:
# Filter by branch
github_workflow_status{branch="main",ref_type="branch"}
# Filter by tag (release workflow)
github_workflow_status{ref_type="tag",trigger="push"}
# Filter by specific tag pattern
github_workflow_status{branch=~"v.*",ref_type="tag"}
We welcome contributions! Please see our Contributing Guidelines for details on how to submit pull requests, report issues, and contribute to the project.
For local development:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes and add tests
- Run tests:
go test ./... - Run linting:
golangci-lint run - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature/your-feature - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Create an issue for bug reports or feature requests
- Contact: @jdunnink
The repository includes a Grafana dashboard (dashboards/state-of-ci.json) that provides visualization of your GitHub Actions metrics.
