|
| 1 | +--- |
1 | 2 | name: CI |
2 | | - |
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - 'v*' |
7 | | - branches: |
8 | | - - main |
9 | 4 | pull_request: |
10 | | - workflow_call: |
| 5 | + push: |
| 6 | + branches: [main, master, 'release-*'] |
| 7 | + tags: ['v*'] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
11 | 11 |
|
12 | 12 | jobs: |
13 | | - build: |
14 | | - name: Build for common architectures |
| 13 | + test_go: |
| 14 | + name: Go tests |
15 | 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 ] |
| 16 | + container: |
| 17 | + # Whenever the Go version is updated here, .promu.yml |
| 18 | + # should also be updated. |
| 19 | + image: quay.io/prometheus/golang-builder:1.26-base |
23 | 20 | steps: |
24 | 21 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
25 | | - - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4 |
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 }} |
| 22 | + - uses: prometheus/promci-setup@5af30ba8c199a91d6c04ebdc3c48e630e355f62d # v0.1.0 |
| 23 | + - run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1 |
31 | 24 |
|
32 | | - build_all: |
33 | | - name: Build for all architectures |
| 25 | + build: |
| 26 | + name: Build |
34 | 27 | 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 | 28 | strategy: |
40 | 29 | matrix: |
41 | | - thread: [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ] |
| 30 | + thread: [ 0, 1, 2, 3] |
42 | 31 | steps: |
43 | 32 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
44 | | - - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4 |
45 | | - - uses: ./.github/promci/actions/build |
| 33 | + - uses: prometheus/promci/build@9c86752f3395e08c57719af549cc455d8e2c2514 # v0.7.0 |
46 | 34 | with: |
47 | | - parallelism: 12 |
| 35 | + parallelism: 4 |
48 | 36 | thread: ${{ matrix.thread }} |
49 | 37 |
|
50 | | - verify-example-configs: |
51 | | - name: Verify |
52 | | - runs-on: ubuntu-latest |
53 | | - container: |
54 | | - image: quay.io/prometheus/golang-builder:1.25-base |
55 | | - steps: |
56 | | - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.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 | 38 | publish_main: |
62 | 39 | name: Publish main branch artifacts |
63 | 40 | runs-on: ubuntu-latest |
64 | | - needs: [build_all, verify-example-configs] |
| 41 | + needs: [test_go, build] |
65 | 42 | if: | |
66 | | - (github.repository == 'prometheus-community/fortigate_exporter') |
67 | | - && |
68 | 43 | (github.event_name == 'push' && github.event.ref == 'refs/heads/main') |
| 44 | + || |
| 45 | + (github.event_name == 'push' && github.event.ref == 'refs/heads/master') |
69 | 46 | steps: |
70 | 47 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
71 | | - - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4 |
72 | | - - uses: ./.github/promci/actions/publish_main |
| 48 | + - uses: prometheus/promci/publish_main@9c86752f3395e08c57719af549cc455d8e2c2514 # v0.7.0 |
73 | 49 | with: |
74 | 50 | docker_hub_organization: prometheuscommunity |
75 | | - docker_hub_login: ${{ secrets.docker_hub_login }} |
76 | 51 | docker_hub_password: ${{ secrets.docker_hub_password }} |
77 | 52 | quay_io_organization: prometheuscommunity |
78 | | - quay_io_login: ${{ secrets.quay_io_login }} |
79 | 53 | quay_io_password: ${{ secrets.quay_io_password }} |
80 | 54 |
|
81 | 55 | publish_release: |
82 | | - name: Publish release artifacts |
| 56 | + name: Publish release artefacts |
83 | 57 | runs-on: ubuntu-latest |
84 | | - needs: [build_all, verify-example-configs] |
| 58 | + needs: [test_go, build] |
85 | 59 | if: | |
86 | | - (github.repository == 'prometheus-community/fortigate_exporter') |
87 | | - && |
88 | 60 | (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) |
89 | 61 | steps: |
90 | 62 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
91 | | - - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4 |
92 | | - - uses: ./.github/promci/actions/publish_release |
| 63 | + - uses: prometheus/promci/publish_release@9c86752f3395e08c57719af549cc455d8e2c2514 # v0.7.0 |
93 | 64 | with: |
94 | 65 | docker_hub_organization: prometheuscommunity |
95 | | - docker_hub_login: ${{ secrets.docker_hub_login }} |
96 | 66 | docker_hub_password: ${{ secrets.docker_hub_password }} |
97 | 67 | quay_io_organization: prometheuscommunity |
98 | | - quay_io_login: ${{ secrets.quay_io_login }} |
99 | 68 | quay_io_password: ${{ secrets.quay_io_password }} |
100 | 69 | github_token: ${{ secrets.PROMBOT_GITHUB_TOKEN }} |
0 commit comments