summaryrefslogtreecommitdiffstats
path: root/.github/workflows/generate-integrations.yml
blob: 4128e992561bd20d9c24378feef5417b5a01089a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
# CI workflow used to regenerate `integrations/integrations.js` and accompanying documentation when relevant source files are changed.
name: Generate Integrations
on:
  push:
    branches:
      - master
    paths: # If any of these files change, we need to regenerate integrations.js.
      - 'collectors/**/metadata.yaml'
      - 'exporting/**/metadata.yaml'
      - 'health/notifications/**/metadata.yaml'
      - 'integrations/templates/**'
      - 'integrations/categories.yaml'
      - 'integrations/deploy.yaml'
      - 'integrations/cloud-notifications/metadata.yaml'
      - 'integrations/gen_integrations.py'
      - 'packaging/go.d.version'
  workflow_dispatch: null
concurrency: # This keeps multiple instances of the job from running concurrently for the same ref.
  group: integrations-${{ github.ref }}
  cancel-in-progress: true
jobs:
  generate-integrations:
    name: Generate Integrations
    runs-on: ubuntu-latest
    if: github.repository == 'netdata/netdata'
    steps:
      - name: Checkout Agent
        id: checkout-agent
        uses: actions/checkout@v4
        with:
          fetch-depth: 1
          submodules: recursive
      - name: Get Go Ref
        id: get-go-ref
        run: echo "go_ref=$(cat packaging/go.d.version)" >> "${GITHUB_ENV}"
      - name: Checkout Go
        id: checkout-go
        uses: actions/checkout@v4
        with:
          fetch-depth: 1
          path: go.d.plugin
          repository: netdata/go.d.plugin
          ref: ${{ env.go_ref }}
      - name: Prepare Dependencies
        id: prep-deps
        run: |
          sudo apt-get install python3-venv
          python3 -m venv ./virtualenv
          source ./virtualenv/bin/activate
          pip install jsonschema referencing jinja2 ruamel.yaml
      - name: Generate Integrations
        id: generate
        run: |
          source ./virtualenv/bin/activate
          python3 integrations/gen_integrations.py
      - name: Generate Integrations Documentation
        id: generate-integrations-documentation
        run: |
          python3 integrations/gen_docs_integrations.py
      - name: Generate collectors/COLLECTORS.md
        id: generate-collectors-md
        run: |
          python3 integrations/gen_doc_collector_page.py
      - name: Clean Up Temporary Data
        id: clean
        run: rm -rf go.d.plugin virtualenv
      - name: Create PR
        id: create-pr
        uses: peter-evans/create-pull-request@v5
        with:
          token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
          commit-message: Regenerate integrations.js
          branch: integrations-regen
          title: Regenerate integrations.js
          body: |
            Regenerate `integrations/integrations.js`, and documentation based on the
            latest code.

            This PR was auto-generated by
            `.github/workflows/generate-integrations.yml`.
      - name: Failure Notification
        uses: rtCamp/action-slack-notify@v2
        env:
          SLACK_COLOR: 'danger'
          SLACK_FOOTER: ''
          SLACK_ICON_EMOJI: ':github-actions:'
          SLACK_TITLE: 'Integrations regeneration failed:'
          SLACK_USERNAME: 'GitHub Actions'
          SLACK_MESSAGE: |-
              ${{ github.repository }}: Failed to create PR rebuilding integrations.js
              Checkout Agent: ${{ steps.checkout-agent.outcome }}
              Get Go Ref: ${{ steps.get-go-ref.outcome }}
              Checkout Go: ${{ steps.checkout-go.outcome }}
              Prepare Dependencies: ${{ steps.prep-deps.outcome }}
              Generate Integrations: ${{ steps.generate.outcome }}
              Generate Integrations Documentation: ${{ steps.generate-integrations-documentation.outcome }}
              Generate collectors/COLLECTORS.md: ${{ steps.generate-collectors-md.outcome }}
              Clean Up Temporary Data: ${{ steps.clean.outcome }}
              Create PR: ${{ steps.create-pr.outcome }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: >-
          ${{
            failure()
            && startsWith(github.ref, 'refs/heads/master')
            && github.repository == 'netdata/netdata'
          }}