generate-integrations.yml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. - 'collectors/**/multi_metadata.yaml'
  12. - 'integrations/templates/**'
  13. - 'integrations/categories.yaml'
  14. - 'integrations/gen_integrations.py'
  15. - 'packaging/go.d.version'
  16. workflow_dispatch: null
  17. concurrency: # This keeps multiple instances of the job from running concurrently for the same ref.
  18. group: integrations-${{ github.ref }}
  19. cancel-in-progress: true
  20. jobs:
  21. generate-integrations:
  22. name: Generate Integrations
  23. runs-on: ubuntu-latest
  24. steps:
  25. - name: Checkout Agent
  26. id: checkout-agent
  27. uses: actions/checkout@v3
  28. with:
  29. fetch-depth: 1
  30. submodules: recursive
  31. - name: Get Go Ref
  32. id: get-go-ref
  33. run: echo "go_ref=$(cat packaging/go.d.version)" >> "${GITHUB_ENV}"
  34. - name: Checkout Go
  35. id: checkout-go
  36. uses: actions/checkout@v3
  37. with:
  38. fetch-depth: 1
  39. path: go.d.plugin
  40. repository: netdata/go.d.plugin
  41. ref: ${{ env.go_ref }}
  42. - name: Prepare Dependencies
  43. id: prep-deps
  44. run: sudo apt-get install python3-jsonschema python3-referencing python3-jinja2 python3-ruamel.yaml
  45. - name: Generate Integrations
  46. id: generate
  47. run: integrations/gen_integrations.py
  48. - name: Clean Up Go Repo
  49. id: clean-go
  50. run: rm -rf go.d.plugin
  51. - name: Create PR
  52. id: create-pr
  53. uses: peter-evans/create-pull-request@v5
  54. with:
  55. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  56. commit-message: Regenerate integrations.js
  57. branch: integrations-regen
  58. title: Regenerate integrations.js
  59. body: |
  60. Regenerate `integrations/integrations.js` based on the
  61. latest code.
  62. This PR was auto-generated by
  63. `.github/workflows/generate-integrations.yml`.
  64. - name: Failure Notification
  65. uses: rtCamp/action-slack-notify@v2
  66. env:
  67. SLACK_COLOR: 'danger'
  68. SLACK_FOOTER: ''
  69. SLACK_ICON_EMOJI: ':github-actions:'
  70. SLACK_TITLE: 'Integrations regeneration failed:'
  71. SLACK_USERNAME: 'GitHub Actions'
  72. SLACK_MESSAGE: |-
  73. ${{ github.repository }}: Failed to create PR rebuilding integrations.js
  74. Checkout Agent: ${{ steps.checkout-agent.outcome }}
  75. Get Go Ref: ${{ steps.get-go-ref.outcome }}
  76. Checkout Go: ${{ steps.checkout-go.outcome }}
  77. Prepare Dependencies: ${{ steps.prep-deps.outcome }}
  78. Generate Integrations: ${{ steps.generate.outcome }}
  79. Clean Up Go Repository: ${{ steps.clean-go.outcome }}
  80. Create PR: ${{ steps.create-pr.outcome }}
  81. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  82. if: >-
  83. ${{
  84. failure()
  85. && startsWith(github.ref, 'refs/heads/master')
  86. && github.repository == 'netdata/netdata'
  87. }}