Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add initial rustdocs workflow #1042

Merged
merged 13 commits into from
Dec 15, 2024
54 changes: 54 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build and Deploy Crate Docs to Vercel

on:
push:
branches: [main]
tags:
- v*.*.*
pull_request:
branches: [main]

jobs:
docs:
permissions:
contents: write
packages: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
runs-on:
- runs-on=${{ github.run_id }}
- runner=8cpu-linux-arm64
steps:
- uses: actions/checkout@v4
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@nightly

# TEMPORARY
- name: Give GitHub Actions access to private repositories
uses: webfactory/[email protected]
with:
ssh-private-key: |
${{ secrets.GH_ACTIONS_DEPLOY_PRIVATE_KEY }}

- name: Build documentation
run: cargo doc --workspace --no-deps
yi-sun marked this conversation as resolved.
Show resolved Hide resolved
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
# taken from https://github.com/paradigmxyz/reth/blob/main/.github/workflows/book.yml
RUSTDOCFLAGS: --cfg docsrs --show-type-layout --generate-link-to-definition --enable-index-page -Zunstable-options --html-in-header assets/head.html

# TODO: make a special tag for doc commit when pushing v*.*.* tags

- name: Install Vercel CLI
run: npm install -g vercel

- name: Deploy to Vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} # Token stored in GitHub Secrets
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_DOCS_PROJECT_ID }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
run: |
cd target/doc
mkdir .vercel
echo "{\"projectId\":\"$VERCEL_PROJECT_ID\",\"orgId\":\"$VERCEL_ORG_ID\"}" > .vercel/project.json
vercel --prod --token $VERCEL_TOKEN
1 change: 1 addition & 0 deletions assets/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<base href="/" />