openapi.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
  16. with:
  17. ref: ${{ github.event.pull_request.head.sha }}
  18. repository: ${{ github.event.pull_request.head.repo.full_name }}
  19. - name: Setup .NET
  20. uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
  21. with:
  22. dotnet-version: '7.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@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
  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/net7.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@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
  40. with:
  41. ref: ${{ github.event.pull_request.head.sha }}
  42. repository: ${{ github.event.pull_request.head.repo.full_name }}
  43. fetch-depth: 0
  44. - name: Checkout common ancestor
  45. run: |
  46. git remote add upstream https://github.com/${{ github.event.pull_request.base.repo.full_name }}
  47. git -c protocol.version=2 fetch --prune --progress --no-recurse-submodules upstream +refs/heads/*:refs/remotes/upstream/* +refs/tags/*:refs/tags/*
  48. ANCESTOR_REF=$(git merge-base upstream/${{ github.base_ref }} origin/${{ github.head_ref }})
  49. git checkout --progress --force $ANCESTOR_REF
  50. - name: Setup .NET
  51. uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
  52. with:
  53. dotnet-version: '7.0.x'
  54. - name: Generate openapi.json
  55. run: dotnet test tests/Jellyfin.Server.Integration.Tests/Jellyfin.Server.Integration.Tests.csproj -c Release --filter "Jellyfin.Server.Integration.Tests.OpenApiSpecTests"
  56. - name: Upload openapi.json
  57. uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
  58. with:
  59. name: openapi-base
  60. retention-days: 14
  61. if-no-files-found: error
  62. path: tests/Jellyfin.Server.Integration.Tests/bin/Release/net7.0/openapi.json
  63. openapi-diff:
  64. permissions:
  65. pull-requests: write # to create or update comment (peter-evans/create-or-update-comment)
  66. name: OpenAPI - Difference
  67. if: ${{ github.event_name == 'pull_request_target' }}
  68. runs-on: ubuntu-latest
  69. needs:
  70. - openapi-head
  71. - openapi-base
  72. steps:
  73. - name: Download openapi-head
  74. uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
  75. with:
  76. name: openapi-head
  77. path: openapi-head
  78. - name: Download openapi-base
  79. uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
  80. with:
  81. name: openapi-base
  82. path: openapi-base
  83. - name: Workaround openapi-diff issue
  84. run: |
  85. sed -i 's/"allOf"/"oneOf"/g' openapi-head/openapi.json
  86. sed -i 's/"allOf"/"oneOf"/g' openapi-base/openapi.json
  87. - name: Calculate OpenAPI difference
  88. uses: docker://openapitools/openapi-diff
  89. continue-on-error: true
  90. with:
  91. args: --fail-on-changed --markdown openapi-changes.md openapi-base/openapi.json openapi-head/openapi.json
  92. - id: read-diff
  93. name: Read openapi-diff output
  94. run: |
  95. body=$(cat openapi-changes.md)
  96. body="${body//'%'/'%25'}"
  97. body="${body//$'\n'/'%0A'}"
  98. body="${body//$'\r'/'%0D'}"
  99. echo ::set-output name=body::$body
  100. - name: Find difference comment
  101. uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0
  102. id: find-comment
  103. with:
  104. issue-number: ${{ github.event.pull_request.number }}
  105. direction: last
  106. body-includes: openapi-diff-workflow-comment
  107. - name: Reply or edit difference comment (changed)
  108. uses: peter-evans/create-or-update-comment@ca08ebd5dc95aa0cd97021e9708fcd6b87138c9b # v3.0.1
  109. if: ${{ steps.read-diff.outputs.body != '' }}
  110. with:
  111. issue-number: ${{ github.event.pull_request.number }}
  112. comment-id: ${{ steps.find-comment.outputs.comment-id }}
  113. edit-mode: replace
  114. body: |
  115. <!--openapi-diff-workflow-comment-->
  116. <details>
  117. <summary>Changes in OpenAPI specification found. Expand to see details.</summary>
  118. ${{ steps.read-diff.outputs.body }}
  119. </details>
  120. - name: Edit difference comment (unchanged)
  121. uses: peter-evans/create-or-update-comment@ca08ebd5dc95aa0cd97021e9708fcd6b87138c9b # v3.0.1
  122. if: ${{ steps.read-diff.outputs.body == '' && steps.find-comment.outputs.comment-id != '' }}
  123. with:
  124. issue-number: ${{ github.event.pull_request.number }}
  125. comment-id: ${{ steps.find-comment.outputs.comment-id }}
  126. edit-mode: replace
  127. body: |
  128. <!--openapi-diff-workflow-comment-->
  129. No changes to OpenAPI specification found. See history of this comment for previous changes.