Skip to content

Commit afcfb5f

Browse files
authored
Enable CI (#314)
Add GitHub Actions CI build and publish workflow. Signed-off-by: SuperQ <superq@gmail.com>
1 parent fafbd96 commit afcfb5f

2 files changed

Lines changed: 109 additions & 3 deletions

File tree

.github/dependabot.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "gomod"
4-
directory: "/"
3+
- package-ecosystem: gomod
4+
directory: /
55
schedule:
6-
interval: "monthly"
6+
interval: monthly
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: github-actions
9+
directory: /
10+
schedule:
11+
interval: monthly
12+
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
branches:
8+
- main
9+
pull_request:
10+
workflow_call:
11+
12+
jobs:
13+
build:
14+
name: Build for common architectures
15+
runs-on: ubuntu-latest
16+
if: |
17+
!(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
18+
&&
19+
!(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
20+
strategy:
21+
matrix:
22+
thread: [ 0, 1, 2 ]
23+
steps:
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
26+
- uses: ./.github/promci/actions/build
27+
with:
28+
promu_opts: "-p linux/amd64 -p windows/amd64 -p darwin/amd64 -p linux/arm64 -p windows/arm64 -p darwin/arm64"
29+
parallelism: 3
30+
thread: ${{ matrix.thread }}
31+
32+
build_all:
33+
name: Build for all architectures
34+
runs-on: ubuntu-latest
35+
if: |
36+
(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
37+
||
38+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
39+
strategy:
40+
matrix:
41+
thread: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]
42+
steps:
43+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
44+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
45+
- uses: ./.github/promci/actions/build
46+
with:
47+
parallelism: 12
48+
thread: ${{ matrix.thread }}
49+
50+
verify-example-configs:
51+
name: Verify
52+
runs-on: ubuntu-latest
53+
container:
54+
image: quay.io/prometheus/golang-builder:1.23-base
55+
steps:
56+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
57+
- run: make build
58+
- name: Verify example configs
59+
run: find ./examples -name "*.yml" -print0 | xargs -0 -I % ./yace verify-config -config.file %
60+
61+
publish_main:
62+
name: Publish main branch artifacts
63+
runs-on: ubuntu-latest
64+
needs: [build_all, verify-example-configs]
65+
if: |
66+
(github.repository == 'prometheus-community/fortigate-exporter')
67+
&&
68+
(github.event_name == 'push' && github.event.ref == 'refs/heads/main')
69+
steps:
70+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
71+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
72+
- uses: ./.github/promci/actions/publish_main
73+
with:
74+
docker_hub_organization: prometheuscommunity
75+
docker_hub_login: ${{ secrets.docker_hub_login }}
76+
docker_hub_password: ${{ secrets.docker_hub_password }}
77+
quay_io_organization: prometheuscommunity
78+
quay_io_login: ${{ secrets.quay_io_login }}
79+
quay_io_password: ${{ secrets.quay_io_password }}
80+
81+
publish_release:
82+
name: Publish release artifacts
83+
runs-on: ubuntu-latest
84+
needs: [build_all, verify-example-configs]
85+
if: |
86+
(github.repository == 'prometheus-community/fortigate-exporter')
87+
&&
88+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v0.'))
89+
steps:
90+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
91+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
92+
- uses: ./.github/promci/actions/publish_release
93+
with:
94+
docker_hub_organization: prometheuscommunity
95+
docker_hub_login: ${{ secrets.docker_hub_login }}
96+
docker_hub_password: ${{ secrets.docker_hub_password }}
97+
quay_io_organization: prometheuscommunity
98+
quay_io_login: ${{ secrets.quay_io_login }}
99+
quay_io_password: ${{ secrets.quay_io_password }}
100+
github_token: ${{ secrets.PROMBOT_GITHUB_TOKEN }}

0 commit comments

Comments
 (0)