openapi.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. name: OpenAPI
  2. on:
  3. push:
  4. branches:
  5. - master
  6. pull_request_target:
  7. permissions: {}
  8. jobs:
  9. openapi-head:
  10. name: OpenAPI - HEAD
  11. runs-on: ubuntu-latest
  12. permissions: read-all
  13. steps:
  14. - name: Checkout repository
  15. uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
  16. with:
  17. ref: ${{ github.event.pull_request.head.sha }}
  18. repository: ${{ github.event.pull_request.head.repo.full_name }}
  19. - name: Setup .NET Core
  20. uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3
  21. with:
  22. dotnet-version: '6.0.x'
  23. - name: Generate openapi.json
  24. run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
  25. - name: Upload openapi.json
  26. uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # tag=v3
  27. with:
  28. name: openapi-head
  29. retention-days: 14
  30. if-no-files-found: error
  31. path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net6.0/openapi.json
  32. openapi-base:
  33. name: OpenAPI - BASE
  34. if: ${{ github.base_ref != '' }}
  35. runs-on: ubuntu-latest
  36. permissions: read-all
  37. steps:
  38. - name: Checkout repository
  39. uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3
  40. with:
  41. ref: ${{ github.base_ref }}
  42. - name: Setup .NET Core
  43. uses: actions/setup-dotnet@607fce577a46308457984d59e4954e075820f10a # tag=v3
  44. with:
  45. dotnet-version: '6.0.x'
  46. - name: Generate openapi.json
  47. run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
  48. - name: Upload openapi.json
  49. uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # tag=v3
  50. with:
  51. name: openapi-base
  52. retention-days: 14
  53. if-no-files-found: error
  54. path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net6.0/openapi.json
  55. openapi-diff:
  56. permissions:
  57. pull-requests: write # to create or update comment (peter-evans/create-or-update-comment)
  58. name: OpenAPI - Difference
  59. if: ${{ github.event_name == 'pull_request_target' }}
  60. runs-on: ubuntu-latest
  61. needs:
  62. - openapi-head
  63. - openapi-base
  64. steps:
  65. - name: Download openapi-head
  66. uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # tag=v3
  67. with:
  68. name: openapi-head
  69. path: openapi-head
  70. - name: Download openapi-base
  71. uses: actions/download-artifact@9782bd6a9848b53b110e712e20e42d89988822b7 # tag=v3
  72. with:
  73. name: openapi-base
  74. path: openapi-base
  75. - name: Workaround openapi-diff issue
  76. run: |
  77. sed -i 's/"allOf"/"oneOf"/g' openapi-head/openapi.json
  78. sed -i 's/"allOf"/"oneOf"/g' openapi-base/openapi.json
  79. - name: Calculate OpenAPI difference
  80. uses: docker://openapitools/openapi-diff
  81. continue-on-error: true
  82. with:
  83. args: --fail-on-changed --markdown openapi-changes.md openapi-base/openapi.json openapi-head/openapi.json
  84. - id: read-diff
  85. name: Read openapi-diff output
  86. run: |
  87. body=$(cat openapi-changes.md)
  88. body="${body//'%'/'%25'}"
  89. body="${body//$'\n'/'%0A'}"
  90. body="${body//$'\r'/'%0D'}"
  91. echo ::set-output name=body::$body
  92. - name: Find difference comment
  93. uses: peter-evans/find-comment@f4499a714d59013c74a08789b48abe4b704364a0 # v2
  94. id: find-comment
  95. with:
  96. issue-number: ${{ github.event.pull_request.number }}
  97. direction: last
  98. body-includes: openapi-diff-workflow-comment
  99. - name: Reply or edit difference comment (changed)
  100. uses: peter-evans/create-or-update-comment@5adcb0bb0f9fb3f95ef05400558bdb3f329ee808 # tag=v2
  101. if: ${{ steps.read-diff.outputs.body != '' }}
  102. with:
  103. issue-number: ${{ github.event.pull_request.number }}
  104. comment-id: ${{ steps.find-comment.outputs.comment-id }}
  105. edit-mode: replace
  106. body: |
  107. <!--openapi-diff-workflow-comment-->
  108. <details>
  109. <summary>Changes in OpenAPI specification found. Expand to see details.</summary>
  110. ${{ steps.read-diff.outputs.body }}
  111. </details>
  112. - name: Edit difference comment (unchanged)
  113. uses: peter-evans/create-or-update-comment@5adcb0bb0f9fb3f95ef05400558bdb3f329ee808 # tag=v2
  114. if: ${{ steps.read-diff.outputs.body == '' && steps.find-comment.outputs.comment-id != '' }}
  115. with:
  116. issue-number: ${{ github.event.pull_request.number }}
  117. comment-id: ${{ steps.find-comment.outputs.comment-id }}
  118. edit-mode: replace
  119. body: |
  120. <!--openapi-diff-workflow-comment-->
  121. No changes to OpenAPI specification found. See history of this comment for previous changes.