|
| 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@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 }} |
| 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 44 | + - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4 |
| 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.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 | + 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 71 | + - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4 |
| 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/v')) |
| 89 | + steps: |
| 90 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 91 | + - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4 |
| 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