Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/build-rest-api.yml
Original file line number Diff line number Diff line change
@@ -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 \
8 changes: 4 additions & 4 deletions docs/jobs/pre-build-job.sh
Original file line number Diff line number Diff line change
@@ -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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you named your workflow with underscores instead of hyphens

Suggested change
WORKFLOW="build-rest-api.yml"
WORKFLOW="build_rest_api.yml"

ARTIFACT_NAME="openapi-spec"
TARGET_DIR="${SOURCEDIR}/_html_extra/reference/api"

mkdir -p "${TARGET_DIR}"
Expand All @@ -15,6 +14,7 @@ RUN_IDS=$(gh run list \
-R "${REPO}" \
--workflow "${WORKFLOW}" \
--status success \
--branch master \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://github.com/canonical/snap-docs/pull/199/changes#r2958816628 if we can directly generate the artifact here, we could remove this search from here.

But if keep it, note that this should not be master but it should be this exact branch otherwise there is no use of the above PR job

--limit 100 \
--json databaseId \
-q '.[].databaseId')
Expand Down
Loading