ci(workflow): deploy rustdocs for turbopack (#61958)

### What

We'd like to deploy generated rustdocs from turbopack & related packages
(next-swc), setting up a CI workflow to automate those.

Since we need next.js side packages to build docs, this CI sets up
things in this repo.

Closes PACK-2375.
This commit is contained in:
OJ Kwon 2024-02-12 15:14:36 -08:00 committed by GitHub
parent d87810bc9f
commit b04c70335d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 74 additions and 0 deletions

View file

@ -473,6 +473,31 @@ jobs:
VERCEL_API_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
DEPLOY_ENVIRONMENT: production
deployTurbopackDocs:
name: Deploy Turbopack docs
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 25
- name: Install Vercel CLI
run: npm i -g vercel@latest
- name: Install Rust
uses: ./.github/actions/setup-rust
- name: Deploy preview docs
if: ${{ needs.build.outputs.isRelease != 'true' }}
run: ./scripts/deploy-turbopack-docs.sh
env:
VERCEL_API_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
DEPLOY_ENVIRONMENT: preview
- name: Deploy production docs
if: ${{ needs.build.outputs.isRelease == 'true' }}
run: ./scripts/deploy-turbopack-docs.sh
env:
VERCEL_API_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
DEPLOY_ENVIRONMENT: production
releaseStats:
name: Release Stats
runs-on:

View file

@ -138,6 +138,20 @@ jobs:
stepName: 'rust-check'
secrets: inherit
rust-doc-check:
name: rustdoc check
needs: ['changes', 'build-next']
if: ${{ needs.changes.outputs.docs-only == 'false' }}
uses: ./.github/workflows/build_reusable.yml
with:
needsRust: 'yes'
skipInstallBuild: 'yes'
skipNativeBuild: 'yes'
afterBuild: ./scripts/deploy-turbopack-docs.sh
stepName: 'rust-doc-check'
secrets: inherit
test-turbopack-dev:
name: test turbopack dev
needs: ['changes', 'build-next']

View file

@ -0,0 +1,7 @@
# Turbopack
Welcome to an overview of the Turbopack documentation.
Currently it's work in progress, the only package available is [Turbo tasks-fs](turbo_tasks_fs/index.html)
[comment]: # 'Temporary index page document'

View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
PROD=""
if [ -z ${DEPLOY_ENVIRONMENT+x} ]; then
DEPLOY_ENVIRONMENT=""
else
if [ "$DEPLOY_ENVIRONMENT" = "production" ]; then
PROD="--prod"
fi
fi
RUSTDOCFLAGS="-Z unstable-options --index-page $(pwd)/packages/next-swc/docs/index.md" cargo doc -p turbo-tasks-fs --no-deps
if [ -z ${VERCEL_API_TOKEN+x} ]; then
echo "VERCEL_API_TOKEN was not providing, skipping..."
exit 0
fi
DOCS_OUTDIR="$(pwd)/target/doc"
PROJECT="turbopack-rust-docs"
echo "Deploying directory $DOCS_OUTDIR as $PROJECT to Vercel..."
vercel link --cwd $DOCS_OUTDIR --scope vercel --project $PROJECT --token "$VERCEL_API_TOKEN" --yes
vercel deploy --cwd $DOCS_OUTDIR --token "$VERCEL_API_TOKEN" $PROD