aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci-openapi.yml57
1 files changed, 57 insertions, 0 deletions
diff --git a/.github/workflows/ci-openapi.yml b/.github/workflows/ci-openapi.yml
index b5ccafb86..b80bff129 100644
--- a/.github/workflows/ci-openapi.yml
+++ b/.github/workflows/ci-openapi.yml
@@ -137,3 +137,60 @@ jobs:
<!--openapi-diff-workflow-comment-->
No changes to OpenAPI specification found. See history of this comment for previous changes.
+
+ publish:
+ name: OpenAPI - Publish Unstable Spec
+ if: |
+ github.event_name != 'pull_request' &&
+ contains(github.repository_owner, 'jellyfin')
+ runs-on: ubuntu-latest
+ needs:
+ - openapi-head
+ steps:
+ - name: Set unstable dated version
+ id: version
+ run: |-
+ echo "JELLYFIN_VERSION=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
+ - name: Download openapi-head
+ uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
+ with:
+ name: openapi-head
+ path: openapi-head
+ - name: Upload openapi.json (unstable) to repository server
+ uses: appleboy/scp-action@917f8b81dfc1ccd331fef9e2d61bdc6c8be94634 # v0.1.7
+ with:
+ host: "${{ secrets.REPO_HOST }}"
+ username: "${{ secrets.REPO_USER }}"
+ key: "${{ secrets.REPO_KEY }}"
+ source: openapi-head/openapi.json
+ strip_components: 1
+ target: "/srv/incoming/openapi/unstable/jellyfin-openapi-${{ env.JELLYFIN_VERSION }}.json"
+ - name: Move openapi.json (unstable) into place
+ uses: appleboy/ssh-action@029f5b4aeeeb58fdfe1410a5d17f967dacf36262 # v1.0.3
+ with:
+ host: "${{ secrets.REPO_HOST }}"
+ username: "${{ secrets.REPO_USER }}"
+ key: "${{ secrets.REPO_KEY }}"
+ debug: false
+ script_stop: false
+ script: |
+ TGT_DIR="/srv/repository/main/openapi"
+ LAST_SPEC="$( ls -lt ${TGT_DIR}/unstable/ | grep 'jellyfin-openapi' | head -1 | awk '{ print $NF }' )"
+ # If new and previous spec don't differ (diff retcode 0), remove incoming and finish
+ if diff /srv/incoming/openapi/unstable/jellyfin-openapi-${{ env.JELLYFIN_VERSION }}.json ${TGT_DIR}/unstable/${LAST_SPEC} &>/dev/null; then
+ rm /srv/incoming/openapi/unstable/jellyfin-openapi-${{ env.JELLYFIN_VERSION }}.json
+ exit 0
+ fi
+ # Move new spec into place
+ sudo mv /srv/incoming/openapi/unstable/jellyfin-openapi-${{ env.JELLYFIN_VERSION }}.json ${TGT_DIR}/unstable/jellyfin-openapi-${{ env.JELLYFIN_VERSION }}.json
+ # Delete previous jellyfin-openapi-unstable_previous.json
+ sudo rm ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
+ # Move current jellyfin-openapi-unstable.json symlink to jellyfin-openapi-unstable_previous.json
+ sudo mv ${TGT_DIR}/jellyfin-openapi-unstable.json ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
+ # Create new jellyfin-openapi-stable.json symlink
+ sudo ln -s unstable/jellyfin-openapi-${{ env.JELLYFIN_VERSION }}.json ${TGT_DIR}/jellyfin-openapi-unstable.json
+ # Check that the previous openapi spec is correct
+ if [[ "$( readlink ${TGT_DIR}/jellyfin-openapi-unstable_previous.json )" != "unstable/${LAST_SPEC}" ]]; then
+ sudo rm ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
+ sudo ln -s unstable/${LAST_SPEC} ${TGT_DIR}/jellyfin-openapi-unstable_previous.json
+ fi