Skip to content

Commit 41c3133

Browse files
committed
Merge branch 'feature/refactor' into develop
2 parents 323bdac + 6899c92 commit 41c3133

22 files changed

+1146
-455
lines changed

.github/workflows/release.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ jobs:
1414
- uses: actions/checkout@master
1515
- uses: actions/setup-go@v2
1616
with:
17-
go-version: '1.15'
17+
go-version: '1.16'
18+
19+
- name: Get the version
20+
id: get_version
21+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
1822

1923
- name: Build
20-
run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o github-actions-exporter
24+
run: CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-X 'main.version=${{ steps.get_version.outputs.VERSION }}'" -o github-actions-exporter
2125

2226
- name: Create Release
2327
id: create_release

Dockerfile

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
FROM golang:1.15 as builder
2-
1+
FROM golang:1.16 as builder
32

43
WORKDIR /app
54
COPY . .
6-
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o bin/app
5+
RUN bash ./build.sh
76

87
FROM alpine:latest as release
98
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*

README.md

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# github-actions-exporter
22
github-actions-exporter for prometheus
33

4+
![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/spendeskplatform/github-actions-exporter)
5+
![Docker Pulls](https://img.shields.io/docker/pulls/spendeskplatform/github-actions-exporter)
6+
[![Go Report Card](https://goreportcard.com/badge/github.com/Spendesk/github-actions-exporter)](https://goreportcard.com/report/github.com/Spendesk/github-actions-exporter)
7+
8+
Container image : https://hub.docker.com/repository/docker/spendeskplatform/github-actions-exporter
9+
410
## Information
511
If you want to monitor a public repository, you must put the public_repo option in the repo scope of your github token.
612

@@ -12,10 +18,11 @@ If you want to monitor a public repository, you must put the public_repo option
1218
| Github Organizations | github_orgas, go | GITHUB_ORGAS | - | List all organizations you want get informations. Format \<orga1>,\<orga2>,\<orga3> (like test1,test2) |
1319
| Github Repos | github_repos, grs | GITHUB_REPOS | - | List all repositories you want get informations. Format \<orga>/\<repo>,\<orga>/\<repo2>,\<orga>/\<repo3> (like test/test) |
1420
| Exporter port | port, p | PORT | 9999 | Exporter port |
21+
| Github Api URL | github_api_url, url | GITHUB_API_URL | api.github.com | Github API URL (primarily for Github Enterprise usage) |
1522

1623
## Exported stats
1724

18-
### github_job
25+
### github_workflow_run_status
1926
Gauge type
2027

2128
**Result possibility**
@@ -41,6 +48,32 @@ Gauge type
4148
| workflow | Workflow Name |
4249
| status | Workflow status (completed/in_progress) |
4350

51+
### github_workflow_run_duration_ms
52+
Gauge type
53+
54+
**Result possibility**
55+
56+
| Gauge | Description |
57+
|---|---|
58+
| milliseconds | Number of milliseconds that a specific workflow run took time to complete. |
59+
60+
**Fields**
61+
62+
| Name | Description |
63+
|---|---|
64+
| event | Event type like push/pull_request/...|
65+
| head_branch | Branch name |
66+
| head_sha | Commit ID |
67+
| node_id | Node ID (github actions) (mandatory ??) |
68+
| repo | Repository like \<org>/\<repo> |
69+
| run_number | Build id for the repo (incremental id => 1/2/3/4/...) |
70+
| workflow_id | Workflow ID |
71+
| workflow | Workflow Name |
72+
| status | Workflow status (completed/in_progress) |
73+
74+
### github_job
75+
> :warning: **This is a duplicate of the `github_workflow_run_status` metric that will soon be deprecated, do not use anymore.**
76+
4477
### github_runner_status
4578
Gauge type
4679
(If you have self hosted runner)
@@ -104,7 +137,7 @@ Gauge type
104137
| repo | Repository like \<org>/\<repo> |
105138
| status | Workflow status |
106139

107-
Es:
140+
Example:
108141

109142
```
110143
# HELP github_workflow_usage Number of billable seconds used by a specific workflow during the current billing cycle. Any job re-runs are also included in the usage. Only apply to workflows in private repositories that use GitHub-hosted runners.

build.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
5+
VERSION=`git branch | grep '*' | awk '{print $2}'`
6+
if [[ $VERSION == "master" ]];
7+
then
8+
VERSION=`git describe --tags --abbrev=0`
9+
fi
10+
11+
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags="-X 'main.version=$VERSION'" -o bin/app

config/config.go

-56
This file was deleted.

go.mod

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
module github-actions-exporter
22

3-
go 1.13
3+
go 1.16
44

55
require (
6-
github.com/prometheus/client_golang v1.4.0
7-
github.com/urfave/cli v1.22.2
6+
github.com/fasthttp/router v1.3.9 // indirect
7+
github.com/google/go-github/v33 v33.0.1-0.20210311004518-0540c33dca8b // indirect
8+
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
9+
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
10+
github.com/prometheus/client_golang v1.9.0 // indirect
11+
github.com/urfave/cli/v2 v2.3.0 // indirect
12+
github.com/valyala/fasthttp v1.22.0 // indirect
13+
golang.org/x/oauth2 v0.0.0-20210311163135-5366d9dc1934 // indirect
814
)

0 commit comments

Comments
 (0)