ebcc8b7ca9
The actions/setup-node@v6.4.0 upgrade stopped auto-shimming yarn onto PATH via corepack. The yarn-plugin test spawns yarn via Node's child_process.spawn() which does a raw PATH lookup, causing ENOENT failures. Adding corepack: true ensures the yarn shim is available. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Fredrik Adelöw <freben@gmail.com>
320 lines
10 KiB
YAML
320 lines
10 KiB
YAML
name: Deploy Microsite
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
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@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: find latest release branch
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
|
|
id: find-release
|
|
with:
|
|
script: |
|
|
const data = await octokit.paginate(github.rest.repos.listBranches, {
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
per_page: 100,
|
|
})
|
|
|
|
const [{branch}] = data
|
|
.map(i => i.name)
|
|
.filter(branch => branch.match(/^patch\/v\d+\.\d+\.\d+$/))
|
|
.map(branch => ({
|
|
branch,
|
|
val: branch
|
|
.split('/')[1]
|
|
.slice(1)
|
|
.split('.')
|
|
.reduce((val, part) => Number(val) * 1000 + Number(part))
|
|
}))
|
|
.sort((a, b) => b.val - a.val)
|
|
|
|
return branch
|
|
result-encoding: string
|
|
|
|
- name: checkout latest release
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: refs/heads/${{ steps.find-release.outputs.result }}
|
|
|
|
- name: Use Node.js 22.x
|
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
with:
|
|
node-version: 22.x
|
|
registry-url: https://registry.npmjs.org/ # Needed for auth
|
|
corepack: true
|
|
|
|
- name: yarn install
|
|
uses: backstage/actions/yarn-install@2cd6978b476cbdc39fec48346f8b6ca13199dd6a # v0.7.8
|
|
with:
|
|
cache-prefix: ${{ runner.os }}-v22.x
|
|
|
|
# Use the lower-level cache actions for the success cache, so that we can store the cache even on failed builds
|
|
- name: restore package-docs cache
|
|
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
|
with:
|
|
path: .cache/package-docs
|
|
key: ${{ runner.os }}-v${{ matrix.node-version }}-package-docs-stable-${{ github.run_id }}
|
|
restore-keys: |
|
|
${{ runner.os }}-v${{ matrix.node-version }}-package-docs-stable-
|
|
|
|
- name: build API reference
|
|
run: yarn backstage-repo-tools package-docs
|
|
|
|
- name: upload API reference
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
|
with:
|
|
name: stable-reference
|
|
path: type-docs/
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
# Always save success cache even if there were failures, that way it can be used in re-triggered builds
|
|
- name: save package-docs cache
|
|
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
|
if: always()
|
|
with:
|
|
path: .cache/package-docs
|
|
key: ${{ runner.os }}-v${{ matrix.node-version }}-package-docs-stable-${{ github.run_id }}
|
|
|
|
- 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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
|
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@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: checkout master
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Use Node.js 22.x
|
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
with:
|
|
node-version: 22.x
|
|
registry-url: https://registry.npmjs.org/ # Needed for auth
|
|
corepack: true
|
|
|
|
- name: yarn install
|
|
uses: backstage/actions/yarn-install@2cd6978b476cbdc39fec48346f8b6ca13199dd6a # v0.7.8
|
|
with:
|
|
cache-prefix: ${{ runner.os }}-v22.x
|
|
|
|
# Use the lower-level cache actions for the success cache, so that we can store the cache even on failed builds
|
|
- name: restore package-docs cache
|
|
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
|
with:
|
|
path: .cache/package-docs
|
|
key: ${{ runner.os }}-v${{ matrix.node-version }}-package-docs-${{ github.run_id }}
|
|
restore-keys: |
|
|
${{ runner.os }}-v${{ matrix.node-version }}-package-docs-
|
|
|
|
- name: build API reference
|
|
run: yarn backstage-repo-tools package-docs
|
|
|
|
- name: upload API reference
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
|
with:
|
|
name: next-reference
|
|
path: type-docs/
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
# Always save success cache even if there were failures, that way it can be used in re-triggered builds
|
|
- name: save package-docs cache
|
|
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
|
|
if: always()
|
|
with:
|
|
path: .cache/package-docs
|
|
key: ${{ runner.os }}-v${{ matrix.node-version }}-package-docs-${{ github.run_id }}
|
|
|
|
- name: Build Storybook
|
|
run: yarn build-storybook
|
|
|
|
- name: Upload Storybook
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
|
with:
|
|
name: storybook
|
|
path: dist-storybook
|
|
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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
|
with:
|
|
name: next-openapi-docs
|
|
path: docs/**/api/**/*
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
deploy-microsite-and-storybook:
|
|
permissions:
|
|
contents: write # for JamesIves/github-pages-deploy-action to push changes in repo
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
- stable
|
|
- next
|
|
|
|
env:
|
|
CI: true
|
|
NODE_OPTIONS: --max-old-space-size=16384
|
|
DOCUSAURUS_SSR_CONCURRENCY: 5
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: Use Node.js 22.x
|
|
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
|
with:
|
|
node-version: 22.x
|
|
registry-url: https://registry.npmjs.org/ # Needed for auth
|
|
corepack: true
|
|
|
|
# Stable docs
|
|
- name: checkout latest release
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
ref: refs/heads/${{ needs.stable.outputs.release }}
|
|
|
|
- name: microsite yarn install
|
|
run: yarn install --immutable
|
|
working-directory: microsite
|
|
|
|
- name: download stable OpenAPI API docs
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
|
|
with:
|
|
name: stable-openapi-docs
|
|
path: docs
|
|
|
|
- name: grab latest releases docs
|
|
run: |
|
|
git fetch origin master --depth 1
|
|
git checkout FETCH_HEAD -- docs/releases
|
|
|
|
- name: create missing generated file
|
|
run: |
|
|
mkdir -p docs/reference
|
|
cat > docs/reference/index.md <<EOF
|
|
---
|
|
id: 'index'
|
|
title: 'Package Index'
|
|
description: 'Index of all Backstage Packages'
|
|
---
|
|
|
|
Please use [the new API documentation](https://backstage.io/api/stable) for more information.
|
|
|
|
EOF
|
|
|
|
- name: generate stable docs
|
|
run: yarn docusaurus docs:version stable
|
|
working-directory: microsite
|
|
|
|
- name: clear generated docs
|
|
run: git clean -fdx docs/
|
|
|
|
# Next docs
|
|
- name: checkout master
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
clean: false
|
|
|
|
- name: microsite yarn install
|
|
run: yarn install --immutable
|
|
working-directory: microsite
|
|
|
|
- name: download next OpenAPI API docs
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
|
|
with:
|
|
name: next-openapi-docs
|
|
path: docs
|
|
|
|
- name: build microsite
|
|
run: yarn build
|
|
working-directory: microsite
|
|
|
|
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
|
|
with:
|
|
name: storybook
|
|
path: microsite/build/storybook
|
|
|
|
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
|
|
with:
|
|
name: stable-reference
|
|
path: microsite/build/api/stable/
|
|
|
|
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
|
|
with:
|
|
name: next-reference
|
|
path: microsite/build/api/next/
|
|
|
|
- name: Check the build output
|
|
run: ls microsite/build && ls microsite/build/storybook && ls microsite/build/api/stable && ls microsite/build/api/next
|
|
|
|
- name: Deploy both microsite and storybook to gh-pages
|
|
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0
|
|
with:
|
|
branch: gh-pages
|
|
folder: microsite/build
|