Skip to content

Commit

Permalink
update go, ci and add dependabot (#10)
Browse files Browse the repository at this point in the history
Signed-off-by: André Bauer <[email protected]>
  • Loading branch information
monotek authored Jan 22, 2025
1 parent 5e16c88 commit 4bf210e
Show file tree
Hide file tree
Showing 23 changed files with 354 additions and 167 deletions.
4 changes: 4 additions & 0 deletions .github/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- match:
dependency_type: all
update_type: "semver:major"
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
time: "09:00"
timezone: "Europe/Berlin"

- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
time: "09:00"
timezone: "Europe/Berlin"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
time: "09:00"
timezone: "Europe/Berlin"
38 changes: 38 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🧹 Maintenance'
labels:
- 'chore'
- 'dependencies'
version-resolver:
major:
labels:
- 'feature'
minor:
labels:
- 'enhancement'
patch:
labels:
- 'fix'
- 'bugfix'
- 'bug'
- 'chore'
- 'dependencies'
default: patch
template: |
## Changes
$CHANGES
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
92 changes: 92 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
name: ci

permissions: read-all

on:
pull_request:

jobs:
go-lint:
name: go-lint
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: stable

- name: golangci-lint
uses: golangci/golangci-lint-action@v6

go-test:
name: go test
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: go test
run: make test

super-linter:
permissions:
statuses: write
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter/slim@v7
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_CHECKOV: false
VALIDATE_GO: false
VALIDATE_GO_MODULES: false
VALIDATE_JSCPD: false
VALIDATE_SHELL_SHFMT: false
VALIDATE_YAML_PRETTIER: false

docker-build:
needs:
- go-lint
- go-test
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build
id: docker_build
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: false

dependabot-auto-merge:
needs:
- docker-build
- super-linter
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-24.04
if: github.actor == 'dependabot[bot]'
steps:
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
75 changes: 0 additions & 75 deletions .github/workflows/docker-publish.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/release-drafter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Release Drafter

permissions:
contents: read

on:
push:
branches:
- main
pull_request:
types: [opened, reopened, synchronize]

jobs:
update_release_draft:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-24.04
steps:
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 changes: 60 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
name: release

permissions: read-all

on:
push:
branches:
- main
tags:
- 'v*'

jobs:
docker-build-push:
permissions:
contents: read
id-token: write
packages: write
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker metadata action
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM golang:1.19 AS build
FROM golang:1.23 AS build

WORKDIR /app
ADD . .
COPY . .
RUN make build

FROM alpine:3
MAINTAINER Daniel Martins <[email protected]>

COPY --from=build /app/bin/pingdom-exporter /pingdom-exporter
ENTRYPOINT ["/pingdom-exporter"]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GO=CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go
BIN=pingdom-exporter
IMAGE=jusbrasil/$(BIN)
IMAGE=monotek/$(BIN)
DOCKER_BIN=docker

TAG=$(shell git describe --tags)
Expand All @@ -17,7 +17,7 @@ test:

.PHONY: lint
lint:
go get -u golang.org/x/lint/golint
go install golang.org/x/lint/golint@latest
golint ./...

# Build the Docker build stage TARGET
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Pingdom Metrics Exporter for Prometheus

This is a fork of: <https://github.com/camptocamp/prometheus-pingdom-exporter>

Prometheus exporter for uptime metrics exposed by the Pingdom API.

## Running

Make sure you expose the Pingdom API Token via the `PINGDOM_API_TOKEN`
environment variable:

```sh
```bash
# Expose the Pingdom API Token
export PINGDOM_API_TOKEN=<api-token>

Expand All @@ -17,20 +19,20 @@ bin/pingdom-exporter

### Usage

```
```bash
bin/pingdom-exporter -h

Usage of bin/pingdom-exporter:
-default-uptime-slo float
default uptime SLO to be used when the check doesn't provide a uptime SLO tag (i.e. uptime_slo_999 to 99.9% uptime SLO) (default 99)
default uptime SLO to be used when the check doesn't provide a uptime SLO tag (i.e. uptime_slo_999 to 99.9% uptime SLO) (default 99)
-metrics-path string
path under which to expose metrics (default "/metrics")
path under which to expose metrics (default "/metrics")
-outage-check-period int
time (in days) in which to retrieve outage data from the Pingdom API (default 7)
time (in days) in which to retrieve outage data from the Pingdom API (default 7)
-port int
port to listen on (default 9158)
port to listen on (default 9158)
-tags string
tag list separated by commas
tag list separated by commas
```
#### Supported Pingdom Tags
Expand Down
Loading

0 comments on commit 4bf210e

Please sign in to comment.