action.yaml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. name: Services Validation
  2. description: Checks services configuration file and checks for defunct services
  3. inputs:
  4. repositorySecret:
  5. description: GitHub token for API access
  6. required: true
  7. checkApiSecret:
  8. description: Token for server check API
  9. required: false
  10. checkApiServers:
  11. description: Servers for the check API
  12. required: false
  13. runSchemaChecks:
  14. description: Enable schema checking
  15. required: false
  16. default: 'true'
  17. runServiceChecks:
  18. description: Enable defunct service checking
  19. required: false
  20. default: 'false'
  21. createPullRequest:
  22. description: Enable pull request creation after service checks
  23. required: false
  24. default: 'false'
  25. workingDirectory:
  26. description: Working directory for checks
  27. required: false
  28. default: ${{ github.workspace }}
  29. outputs:
  30. hasDefunctServices:
  31. description: True if defunct services were found in configuration
  32. value: ${{ steps.check.outputs.make_pr }}
  33. runs:
  34. using: composite
  35. steps:
  36. - name: Check Runner Operating System 🏃‍♂️
  37. if: runner.os == 'Windows'
  38. shell: bash
  39. run: |
  40. : Check Runner Operating System 🏃‍♂️
  41. echo "::notice::services-validation action requires a macOS-based or Linux-based runner."
  42. exit 2
  43. - name: Install and Configure Python 🐍
  44. shell: bash
  45. run: |
  46. : Install and Configure Python 🐍
  47. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  48. echo ::group::Python Set Up
  49. if [[ "${RUNNER_OS}" == Linux ]]; then
  50. eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
  51. echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
  52. brew install --overwrite --quiet python3
  53. fi
  54. python3 -m venv .venv
  55. source .venv/bin/activate
  56. python3 -m pip install jsonschema json_source_map requests aiohttp
  57. echo ::endgroup::
  58. - name: Validate Services File JSON Schema 🕵️
  59. if: fromJSON(inputs.runSchemaChecks)
  60. shell: bash
  61. working-directory: ${{ inputs.workingDirectory }}
  62. run: |
  63. : Validate Services File JSON Schema 🕵️
  64. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  65. shopt -s extglob
  66. echo ::group::Run Validation
  67. source .venv/bin/activate
  68. python3 -u \
  69. .github/scripts/utils.py/check-jsonschema.py \
  70. plugins/rtmp-services/data/@(services|package).json \
  71. --loglevel INFO
  72. echo ::endgroup::
  73. - name: Annotate schema validation errors 🏷️
  74. if: fromJSON(inputs.runSchemaChecks) && failure()
  75. uses: yuzutech/annotations-action@0e061a6e3ac848299310b6429b60d67cafd4e7f8
  76. with:
  77. repo-token: ${{ inputs.repositorySecret }}
  78. title: Service JSON Errors
  79. input: ${{ inputs.workingDirectory }}/validation_errors.json
  80. - name: Restore Timestamp Cache ⏳
  81. if: fromJSON(inputs.runServiceChecks)
  82. uses: actions/cache@v4
  83. with:
  84. path: ${{ github.workspace }}/other
  85. key: service-check-${{ github.run_id }}
  86. restore-keys: service-check-
  87. - name: Check for defunct services 📉
  88. id: services-check
  89. if: fromJSON(inputs.runServiceChecks)
  90. shell: bash
  91. working-directory: ${{ inputs.workingDirectory }}
  92. env:
  93. GITHUB_TOKEN: ${{ inputs.repositorySecret }}
  94. WORKFLOW_RUN_ID: ${{ github.run_id }}
  95. REPOSITORY: ${{ github.repository }}
  96. API_KEY: ${{ inputs.checkApiSecret }}
  97. API_SERVERS: ${{ inputs.checkApiServers }}
  98. run: |
  99. : Check for defunct services 📉
  100. source .venv/bin/activate
  101. python3 -u .github/scripts/utils.py/check-services.py
  102. - uses: actions/upload-artifact@v4
  103. if: fromJSON(inputs.runServiceChecks)
  104. with:
  105. name: timestamps
  106. path: ${{ inputs.workingDirectory }}/other/*
  107. - name: Create pull request 🔧
  108. uses: peter-evans/create-pull-request@d121e62763d8cc35b5fb1710e887d6e69a52d3a4
  109. if: fromJSON(inputs.createPullRequest) && fromJSON(inputs.runServiceChecks) && fromJSON(steps.services-check.outputs.make_pr)
  110. with:
  111. author: 'Service Checker <[email protected]>'
  112. commit-message: 'rtmp-services: Remove defunct servers/services'
  113. title: 'rtmp-services: Remove defunct servers/services'
  114. branch: 'automated/clean-services'
  115. body: ${{ fromJSON(steps.services-check.outputs.pr_message) }}
  116. delete-branch: true