diff --git a/.github/workflows/verify_microsite.yml b/.github/workflows/verify_microsite.yml index c46ba57e97..7b6416c878 100644 --- a/.github/workflows/verify_microsite.yml +++ b/.github/workflows/verify_microsite.yml @@ -13,6 +13,166 @@ permissions: contents: read jobs: + stable: + runs-on: ubuntu-latest + concurrency: + group: stable-reference-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + env: + CI: true + NODE_OPTIONS: --max-old-space-size=8192 + + outputs: + release: ${{ steps.find-release.outputs.result }} + + steps: + - name: Harden Runner + uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 + with: + egress-policy: audit + + - name: find latest release + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 + id: find-release + with: + script: | + const { data } = await github.rest.repos.listTags({ + owner: context.repo.owner, + repo: context.repo.repo, + per_page: 100, + }) + + const [{tag}] = data + .map(i => i.name) + .filter(tag => tag.match(/^v\d+\.\d+\.\d+$/)) + .map(tag => ({ + tag, + val: tag + .slice(1) + .split('.') + .reduce((val, part) => Number(val) * 1000 + Number(part)) + })) + .sort((a, b) => b.val - a.val) + + return tag + result-encoding: string + + - name: checkout latest release + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: refs/tags/${{ steps.find-release.outputs.result }} + + - name: Use Node.js 20.x + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 + with: + node-version: 20.x + registry-url: https://registry.npmjs.org/ # Needed for auth + + - name: yarn install + uses: backstage/actions/yarn-install@b3c1841fd69e1658ac631afafd0fb140a2309024 # v0.6.17 + with: + cache-prefix: ${{ runner.os }}-v20.x + + - name: build API reference + run: yarn build:api-docs + + - name: upload API reference + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: stable-reference + path: docs/reference/ + if-no-files-found: error + retention-days: 1 + + - name: microsite yarn install + run: yarn install --immutable + working-directory: microsite + + - name: build OpenAPI API docs + working-directory: microsite + run: yarn docusaurus gen-api-docs all + + - name: upload OpenAPI API docs + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: stable-openapi-docs + path: docs/**/api/**/* + if-no-files-found: error + retention-days: 1 + next: + runs-on: ubuntu-latest + concurrency: + group: next-reference-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + env: + CI: true + NODE_OPTIONS: --max-old-space-size=8192 + + steps: + - name: Harden Runner + uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 + with: + egress-policy: audit + + - name: checkout master + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Use Node.js 20.x + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 + with: + node-version: 20.x + registry-url: https://registry.npmjs.org/ # Needed for auth + + - name: yarn install + uses: backstage/actions/yarn-install@b3c1841fd69e1658ac631afafd0fb140a2309024 # v0.6.17 + with: + cache-prefix: ${{ runner.os }}-v20.x + + - name: build API reference + run: yarn build:api-docs + + - name: upload API reference + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: next-reference + path: docs/reference/ + if-no-files-found: error + retention-days: 1 + + # Also build and upload storybook + - name: storybook yarn install + run: yarn install --immutable + working-directory: storybook + + - name: storybook build + run: yarn build-storybook + working-directory: storybook + + - name: storybook upload + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: storybook + path: storybook/dist/ + if-no-files-found: error + retention-days: 1 + + - name: microsite yarn install + run: yarn install --immutable + working-directory: microsite + + - name: build OpenAPI API docs + working-directory: microsite + run: yarn docusaurus gen-api-docs all + + - name: upload OpenAPI API docs + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: next-openapi-docs + path: docs/**/api/**/* + if-no-files-found: error + retention-days: 1 + build-microsite: runs-on: ubuntu-latest @@ -21,6 +181,10 @@ jobs: NODE_OPTIONS: --max-old-space-size=8192 DOCUSAURUS_SSR_CONCURRENCY: 5 + needs: + - stable + - next + name: Microsite steps: - name: Harden Runner @@ -50,19 +214,63 @@ jobs: run: yarn install --immutable working-directory: microsite - - name: build API reference - run: yarn build:api-docs - - - name: Build MkDocs for TechDocs - run: mkdocs build --strict - - - name: verify yarn dependency duplicates - run: node scripts/verify-lockfile-duplicates.js - - name: prettier run: yarn prettier:check working-directory: microsite + - name: verify yarn dependency duplicates + run: node scripts/verify-lockfile-duplicates.js + + - name: download stable reference + uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4 + with: + name: stable-reference + path: docs/reference + + - name: download stable OpenAPI API docs + uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4 + with: + name: stable-openapi-docs + path: docs + + - name: grab lastest releases docs + run: | + git fetch origin master --depth 1 + git checkout FETCH_HEAD -- docs/releases + + - name: generate stable docs + run: yarn docusaurus docs:version stable + working-directory: microsite + + - name: clear API reference + run: rm -r docs/reference + + - name: clear OpenAPI reference + run: find . -name '*.api.mdx' -type f -delete + + - name: build API reference + run: yarn build:api-docs + + - name: checkout master + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + clean: false + + - name: Build MkDocs for TechDocs + run: mkdocs build --strict + + - name: download next reference + uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4 + with: + name: next-reference + path: docs/reference + + - name: download next OpenAPI API docs + uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4 + with: + name: next-openapi-docs + path: docs + - name: build microsite run: yarn build working-directory: microsite