services-json.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. name: Services Validator
  2. on:
  3. push:
  4. paths:
  5. - "plugins/rtmp-services/data/services.json"
  6. - "plugins/rtmp-services/data/package.json"
  7. pull_request:
  8. paths:
  9. - "plugins/rtmp-services/data/services.json"
  10. - "plugins/rtmp-services/data/package.json"
  11. schedule:
  12. - cron: 0 0 * * *
  13. workflow_dispatch:
  14. jobs:
  15. schema:
  16. name: Schema
  17. runs-on: [ubuntu-20.04]
  18. if: ${{ github.repository_owner == 'obsproject' || github.event_name != 'schedule' }}
  19. steps:
  20. - name: Checkout
  21. uses: actions/checkout@v3
  22. - name: Install & Configure Python
  23. run: |
  24. sudo apt install python3.9-dev
  25. python3.9 -m pip install jsonschema json_source_map
  26. - name: Validate Service JSON Schema
  27. run: |
  28. JSON_FILES=(
  29. plugins/rtmp-services/data/services.json
  30. plugins/rtmp-services/data/package.json
  31. )
  32. python3.9 CI/check-jsonschema.py "${JSON_FILES[@]}"
  33. - name: Annotate Errors
  34. if: failure()
  35. uses: yuzutech/[email protected]
  36. with:
  37. repo-token: "${{ secrets.GITHUB_TOKEN }}"
  38. title: "Service JSON Errors"
  39. input: "./validation_errors.json"
  40. service_check:
  41. name: Service Check
  42. runs-on: macos-latest
  43. needs: schema
  44. if: ${{ github.repository_owner == 'obsproject' && github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
  45. steps:
  46. - name: Checkout
  47. uses: actions/checkout@v3
  48. with:
  49. fetch-depth: 0
  50. - name: Restore cache
  51. uses: actions/cache@v3
  52. with:
  53. path: ${{ github.workspace }}/other
  54. # Workaround to create a new cache every time, since a cache key is immutable:
  55. # https://github.com/actions/cache/blob/main/workarounds.md#update-a-cache
  56. key: service-check-${{ github.run_id }}
  57. restore-keys: service-check
  58. - name: Install & Configure Python
  59. run: |
  60. python3 -m pip install requests
  61. - name: Check Services
  62. id: check
  63. run: python3 -u CI/check-services.py
  64. env:
  65. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  66. WORKFLOW_RUN_ID: ${{ github.run_id }}
  67. REPOSITORY: ${{ github.repository }}
  68. - uses: actions/upload-artifact@v3
  69. with:
  70. name: timestamps
  71. path: ${{ github.workspace }}/other/*
  72. - name: Create Pull Request
  73. uses: peter-evans/create-pull-request@36a56dac0739df8d3d8ebb9e6e41026ba248ec27
  74. if: steps.check.outputs.make_pr == 'true'
  75. with:
  76. author: "Service Checker <[email protected]>"
  77. commit-message: "rtmp-services: Remove defunct servers/services"
  78. title: "rtmp-services: Remove defunct servers/services"
  79. branch: "automated/clean-services"
  80. body: ${{ fromJSON(steps.check.outputs.pr_message) }}
  81. delete-branch: true