From fcaececb6e4160107f55cc0435449ab2f5d9b9de Mon Sep 17 00:00:00 2001 From: Robert Fudge Date: Wed, 18 Mar 2026 16:02:39 -0230 Subject: [PATCH 1/5] .github, docs/jobs: update GitHub workflow and pre-build job --- .github/workflows/build_rest_api.yml | 67 ++++++++++++++++++++++++++++ docs/jobs/pre-build-job.sh | 8 ++-- 2 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build_rest_api.yml diff --git a/.github/workflows/build_rest_api.yml b/.github/workflows/build_rest_api.yml new file mode 100644 index 0000000..2fd0fbc --- /dev/null +++ b/.github/workflows/build_rest_api.yml @@ -0,0 +1,67 @@ +# SPDX-FileCopyrightText: 2026 Canonical Ltd +# SPDX-License-Identifier: GPL-3.0-only + +name: Prepare the REST OpenAPI Specification +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + +jobs: + check-api: + runs-on: ubuntu-latest + name: Check REST API documentation changes + outputs: + api_changed: ${{ steps.changed-api.outputs.any_changed }} + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + repository: canonical/snapd + path: ./snapd + fetch-depth: 0 + - name: Check if changes occurred in the API documentation + id: changed-api + uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47.0.0 + with: + files: snapd/docs/api/** + + process-specification: + needs: check-api + if: | + github.event_name == 'workflow_dispatch' || + needs.check-api.outputs.api_changed == 'true' + 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 + + - 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 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') From 2e8793fed1eec53f1098b207ad988b50d6b8578f Mon Sep 17 00:00:00 2001 From: Robert Fudge Date: Thu, 19 Mar 2026 11:30:56 -0230 Subject: [PATCH 2/5] .github: remove conditionals, only trigger from snapd repository --- .github/workflows/build_rest_api.yml | 29 ++-------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build_rest_api.yml b/.github/workflows/build_rest_api.yml index 2fd0fbc..7c63810 100644 --- a/.github/workflows/build_rest_api.yml +++ b/.github/workflows/build_rest_api.yml @@ -3,36 +3,11 @@ name: Prepare the REST OpenAPI Specification on: - workflow_dispatch: - pull_request: - push: - branches: - - master + repository_dispatch: + types: [openapi-updated] jobs: - check-api: - runs-on: ubuntu-latest - name: Check REST API documentation changes - outputs: - api_changed: ${{ steps.changed-api.outputs.any_changed }} - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - repository: canonical/snapd - path: ./snapd - fetch-depth: 0 - - name: Check if changes occurred in the API documentation - id: changed-api - uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47.0.0 - with: - files: snapd/docs/api/** - process-specification: - needs: check-api - if: | - github.event_name == 'workflow_dispatch' || - needs.check-api.outputs.api_changed == 'true' runs-on: ubuntu-latest name: Bundle REST API documentation From ff2219db6eac00feb459215e4541d7a204e6a886 Mon Sep 17 00:00:00 2001 From: Robert Fudge Date: Thu, 19 Mar 2026 12:14:11 -0230 Subject: [PATCH 3/5] .g/workflows: fix build-rest-api filename --- .github/workflows/{build_rest_api.yml => build-rest-api.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{build_rest_api.yml => build-rest-api.yml} (100%) diff --git a/.github/workflows/build_rest_api.yml b/.github/workflows/build-rest-api.yml similarity index 100% rename from .github/workflows/build_rest_api.yml rename to .github/workflows/build-rest-api.yml From fb59803bfaaa5169919af5af79c043b049e62c44 Mon Sep 17 00:00:00 2001 From: Robert Fudge Date: Thu, 19 Mar 2026 18:25:16 -0230 Subject: [PATCH 4/5] .g/workflows: start refactor for improved pipeline --- .github/workflows/build-rest-api.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build-rest-api.yml b/.github/workflows/build-rest-api.yml index 7c63810..334e9ff 100644 --- a/.github/workflows/build-rest-api.yml +++ b/.github/workflows/build-rest-api.yml @@ -5,6 +5,9 @@ name: Prepare the REST OpenAPI Specification on: repository_dispatch: types: [openapi-updated] +env: + SNAPD_BRANCH: ${{ github.event.client_payload.snapd_branch }} + DEPLOY: ${{ github.event.client_payload.snapd_branch == 'main' || github.ref == 'refs/heads/main' }} jobs: process-specification: @@ -18,6 +21,7 @@ jobs: repository: canonical/snapd path: ./snapd fetch-depth: 0 + ref: ${{ env.SNAPD_BRANCH }} - name: Check Licensing/Copyright Compliance uses: docker://fsfe/reuse @@ -40,3 +44,9 @@ jobs: 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 \ + # -d '{"deploy":"${{ env.DEPLOY}}"}' something like this From 30cbe19a460667c49b4c819061b87b97cfd23eb5 Mon Sep 17 00:00:00 2001 From: Robert Fudge Date: Mon, 23 Mar 2026 10:43:19 -0230 Subject: [PATCH 5/5] .g/workflows: remove payload from custom event --- .github/workflows/build-rest-api.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-rest-api.yml b/.github/workflows/build-rest-api.yml index 334e9ff..5ce1d45 100644 --- a/.github/workflows/build-rest-api.yml +++ b/.github/workflows/build-rest-api.yml @@ -4,10 +4,7 @@ name: Prepare the REST OpenAPI Specification on: repository_dispatch: - types: [openapi-updated] -env: - SNAPD_BRANCH: ${{ github.event.client_payload.snapd_branch }} - DEPLOY: ${{ github.event.client_payload.snapd_branch == 'main' || github.ref == 'refs/heads/main' }} + types: [api-updated] jobs: process-specification: @@ -21,7 +18,7 @@ jobs: repository: canonical/snapd path: ./snapd fetch-depth: 0 - ref: ${{ env.SNAPD_BRANCH }} + ref: master - name: Check Licensing/Copyright Compliance uses: docker://fsfe/reuse @@ -49,4 +46,3 @@ jobs: # run: | # curl -X POST -H "Authorization: Bearer ${{ secrets.RTD_PAT }}" \ # https://read-the-docs.com \ - # -d '{"deploy":"${{ env.DEPLOY}}"}' something like this