generate-integrations.yml 3.5 KB

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