diff --git a/.github/workflows/build-rest-api.yml b/.github/workflows/build-rest-api.yml new file mode 100644 index 0000000..5ce1d45 --- /dev/null +++ b/.github/workflows/build-rest-api.yml @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: 2026 Canonical Ltd +# SPDX-License-Identifier: GPL-3.0-only + +name: Prepare the REST OpenAPI Specification +on: + repository_dispatch: + types: [api-updated] + +jobs: + process-specification: + runs-on: ubuntu-latest + name: Bundle REST API documentation + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + repository: canonical/snapd + path: ./snapd + fetch-depth: 0 + ref: master + + - name: Check Licensing/Copyright Compliance + uses: docker://fsfe/reuse + with: + entrypoint: /bin/sh + args: -c "cd docs/api && reuse lint" + + - name: Lint API specification + uses: docker://redocly/cli + with: + args: lint ./docs/api/openapi.yaml + + - name: Bundle OpenAPI to JSON + uses: docker://redocly/cli + with: + args: bundle ./docs/api/openapi.yaml --output ./docs/api/openapi.json --ext json + + - name: Store generated JSON artifact + uses: actions/upload-artifact@v6 + with: + name: openapi-spec + path: docs/api/openapi.json + + #- name: Trigger RTD build + # run: | + # curl -X POST -H "Authorization: Bearer ${{ secrets.RTD_PAT }}" \ + # https://read-the-docs.com \ diff --git a/docs/jobs/pre-build-job.sh b/docs/jobs/pre-build-job.sh index 8e11788..3bb41df 100644 --- a/docs/jobs/pre-build-job.sh +++ b/docs/jobs/pre-build-job.sh @@ -1,10 +1,9 @@ #!/bin/bash # Configuration -REPO="canonical/snapd" -# Ensure this matches the actual filename of your YAML workflow in the snapd repo -WORKFLOW="build-documentation.yaml" -ARTIFACT_NAME="openapi-spec" # Updated to match the new GitHub Action output +REPO="canonical/snap-docs" +WORKFLOW="build-rest-api.yml" +ARTIFACT_NAME="openapi-spec" TARGET_DIR="${SOURCEDIR}/_html_extra/reference/api" mkdir -p "${TARGET_DIR}" @@ -15,6 +14,7 @@ RUN_IDS=$(gh run list \ -R "${REPO}" \ --workflow "${WORKFLOW}" \ --status success \ + --branch master \ --limit 100 \ --json databaseId \ -q '.[].databaseId')