Skip to content

Commit dc8474e

Browse files
committed
initial revision
Signed-off-by: Markus Blaschke <[email protected]>
0 parents  commit dc8474e

20 files changed

+1356
-0
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/github-workflow-exporter
2+
/release-assets

.editorconfig

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
end_of_line = lf
10+
insert_final_newline = true
11+
indent_style = space
12+
indent_size = 4
13+
14+
[Makefile]
15+
indent_style = tab
16+
17+
[{*.yml,*.yaml}]
18+
indent_size = 2
19+
20+
[*.conf]
21+
indent_size = 2
22+
23+
[*.go]
24+
indent_size = 4
25+
indent_style = tab
26+
ij_continuation_indent_size = 4
27+
ij_go_GROUP_CURRENT_PROJECT_IMPORTS = true
28+
ij_go_add_leading_space_to_comments = true
29+
ij_go_add_parentheses_for_single_import = true
30+
ij_go_call_parameters_new_line_after_left_paren = true
31+
ij_go_call_parameters_right_paren_on_new_line = true
32+
ij_go_call_parameters_wrap = off
33+
ij_go_fill_paragraph_width = 80
34+
ij_go_group_stdlib_imports = true
35+
ij_go_import_sorting = goimports
36+
ij_go_keep_indents_on_empty_lines = false
37+
ij_go_local_group_mode = project
38+
ij_go_move_all_imports_in_one_declaration = true
39+
ij_go_move_all_stdlib_imports_in_one_group = true
40+
ij_go_remove_redundant_import_aliases = false
41+
ij_go_run_go_fmt_on_reformat = true
42+
ij_go_use_back_quotes_for_imports = false
43+
ij_go_wrap_comp_lit = off
44+
ij_go_wrap_comp_lit_newline_after_lbrace = true
45+
ij_go_wrap_comp_lit_newline_before_rbrace = true
46+
ij_go_wrap_func_params = off
47+
ij_go_wrap_func_params_newline_after_lparen = true
48+
ij_go_wrap_func_params_newline_before_rparen = true
49+
ij_go_wrap_func_result = off
50+
ij_go_wrap_func_result_newline_after_lparen = true
51+
ij_go_wrap_func_result_newline_before_rparen = true

.github/dependabot.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
8+
- package-ecosystem: "docker"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"
12+
13+
- package-ecosystem: "gomod"
14+
directory: "/"
15+
schedule:
16+
interval: "weekly"

.github/workflows/build-docker.yaml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: build/docker
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
publish:
7+
required: true
8+
type: boolean
9+
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set Swap Space
17+
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
18+
with:
19+
swap-size-gb: 12
20+
21+
- uses: actions/setup-go@v5
22+
with:
23+
go-version-file: 'go.mod'
24+
cache-dependency-path: "go.sum"
25+
check-latest: true
26+
27+
- name: Run Golangci lint
28+
uses: golangci/golangci-lint-action@v4
29+
with:
30+
version: latest
31+
args: --print-resources-usage
32+
33+
build:
34+
name: "build ${{ matrix.Dockerfile }}:${{ matrix.target }}"
35+
needs: lint
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
include:
40+
- Dockerfile: Dockerfile
41+
target: "final-static"
42+
suffix: ""
43+
latest: "auto"
44+
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Set Swap Space
50+
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
51+
with:
52+
swap-size-gb: 12
53+
54+
- uses: actions/setup-go@v5
55+
with:
56+
go-version-file: 'go.mod'
57+
cache-dependency-path: "go.sum"
58+
check-latest: true
59+
60+
- name: Docker meta
61+
id: docker_meta
62+
uses: docker/metadata-action@v5
63+
with:
64+
images: |
65+
${{ github.repository }}
66+
quay.io/${{ github.repository }}
67+
labels: |
68+
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md
69+
flavor: |
70+
latest=${{ matrix.latest }}
71+
suffix=${{ matrix.suffix }}
72+
73+
- name: Set up QEMU
74+
uses: docker/setup-qemu-action@v3
75+
76+
- name: Set up Docker Buildx
77+
uses: docker/setup-buildx-action@v3
78+
79+
- name: Login to DockerHub
80+
uses: docker/login-action@v3
81+
if: ${{ inputs.publish }}
82+
with:
83+
username: ${{ secrets.DOCKERHUB_USERNAME }}
84+
password: ${{ secrets.DOCKERHUB_TOKEN }}
85+
86+
- name: Login to Quay
87+
uses: docker/login-action@v3
88+
if: ${{ inputs.publish }}
89+
with:
90+
registry: quay.io
91+
username: ${{ secrets.QUAY_USERNAME }}
92+
password: ${{ secrets.QUAY_TOKEN }}
93+
94+
- name: ${{ inputs.publish && 'Build and push' || 'Build' }}
95+
uses: docker/build-push-action@v5
96+
with:
97+
context: .
98+
file: ./${{ matrix.Dockerfile }}
99+
target: ${{ matrix.target }}
100+
platforms: linux/amd64,linux/arm64
101+
push: ${{ inputs.publish }}
102+
tags: ${{ steps.docker_meta.outputs.tags }}
103+
labels: ${{ steps.docker_meta.outputs.labels }}

.github/workflows/ci-docker.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: "ci/docker"
2+
3+
on: [pull_request, workflow_dispatch]
4+
5+
jobs:
6+
build:
7+
uses: ./.github/workflows/build-docker.yaml
8+
secrets: inherit
9+
with:
10+
publish: false

.github/workflows/release-assets.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "release/assets"
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set Swap Space
14+
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c
15+
with:
16+
swap-size-gb: 12
17+
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version-file: 'go.mod'
21+
cache-dependency-path: "go.sum"
22+
check-latest: true
23+
24+
- name: Build
25+
run: |
26+
make release-assets
27+
28+
- name: Upload assets to release
29+
uses: svenstaro/upload-release-action@v2
30+
with:
31+
repo_token: ${{ secrets.GITHUB_TOKEN }}
32+
file: ./release-assets/*
33+
tag: ${{ github.ref }}
34+
overwrite: true
35+
file_glob: true

.github/workflows/release-docker.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "release/docker"
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'feature-**'
8+
- 'bugfix-**'
9+
tags:
10+
- '*.*.*'
11+
12+
jobs:
13+
release:
14+
uses: ./.github/workflows/build-docker.yaml
15+
secrets: inherit
16+
with:
17+
publish: ${{ github.event_name != 'pull_request' }}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "schedule/docker"
2+
3+
on:
4+
schedule:
5+
- cron: '45 6 * * 1'
6+
7+
jobs:
8+
schedule:
9+
uses: ./.github/workflows/build-docker.yaml
10+
secrets: inherit
11+
with:
12+
publish: true

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor/
2+
/github-workflow-exporter*
3+
/release-assets
4+
/.vscode

.golangci.yaml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
run:
2+
timeout: 120m
3+
4+
linters:
5+
enable:
6+
- asciicheck
7+
- bidichk
8+
- bodyclose
9+
- errorlint
10+
- exportloopref
11+
- gofmt
12+
- goimports
13+
- gosec
14+
- gomodguard
15+
16+
linters-settings:
17+
gosec:
18+
excludes: []
19+
confidence: low
20+
config:
21+
global:
22+
audit: true
23+
24+
gomodguard:
25+
blocked:
26+
modules:
27+
- "github.com/Azure/go-autorest/autorest/azure/auth":
28+
reason: "deprecated"
29+
30+
issues: {}
31+
32+
output:
33+
sort-results: true

Dockerfile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#############################################
2+
# Build
3+
#############################################
4+
FROM --platform=$BUILDPLATFORM golang:1.22-alpine as build
5+
6+
RUN apk upgrade --no-cache --force
7+
RUN apk add --update build-base make git
8+
9+
WORKDIR /go/src/github.com/webdevops/github-workflow-exporter
10+
11+
# Dependencies
12+
COPY go.mod go.sum .
13+
RUN go mod download
14+
15+
# Compile
16+
COPY . .
17+
RUN make test
18+
ARG TARGETOS TARGETARCH
19+
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build
20+
21+
#############################################
22+
# Test
23+
#############################################
24+
FROM gcr.io/distroless/static as test
25+
USER 0:0
26+
WORKDIR /app
27+
COPY --from=build /go/src/github.com/webdevops/github-workflow-exporter/github-workflow-exporter .
28+
RUN ["./github-workflow-exporter", "--help"]
29+
30+
#############################################
31+
# final-static
32+
#############################################
33+
FROM gcr.io/distroless/static as final-static
34+
ENV LOG_JSON=1
35+
WORKDIR /
36+
COPY --from=test /app .
37+
USER 1000:1000
38+
ENTRYPOINT ["/github-workflow-exporter"]

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2024 WebDevOps
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)