deploy_docs.yml

  1# Generated from xtask::workflows::deploy_docs
  2# Rebuild with `cargo xtask workflows`.
  3name: deploy_docs
  4on:
  5  push:
  6    branches:
  7    - main
  8  workflow_call:
  9    inputs:
 10      channel:
 11        description: channel
 12        type: string
 13        default: ''
 14      commit_sha:
 15        description: commit_sha
 16        type: string
 17        default: ''
 18    secrets:
 19      DOCS_AMPLITUDE_API_KEY:
 20        description: DOCS_AMPLITUDE_API_KEY
 21        required: true
 22      CLOUDFLARE_API_TOKEN:
 23        description: CLOUDFLARE_API_TOKEN
 24        required: true
 25      CLOUDFLARE_ACCOUNT_ID:
 26        description: CLOUDFLARE_ACCOUNT_ID
 27        required: true
 28  workflow_dispatch:
 29    inputs:
 30      channel:
 31        description: 'Docs channel to deploy: nightly, preview, or stable'
 32        type: string
 33        default: ''
 34      commit_sha:
 35        description: Exact commit SHA to checkout and deploy. Defaults to event SHA when omitted.
 36        type: string
 37        default: ''
 38jobs:
 39  deploy_docs:
 40    if: github.repository_owner == 'zed-industries'
 41    name: Build and Deploy Docs
 42    runs-on: namespace-profile-16x32-ubuntu-2204
 43    env:
 44      DOCS_AMPLITUDE_API_KEY: ${{ secrets.DOCS_AMPLITUDE_API_KEY }}
 45      MDBOOK_BOOK__SITE_URL: ${{ steps.resolve-channel.outputs.site_url }}
 46      DOCS_CHANNEL: ${{ steps.resolve-channel.outputs.channel }}
 47    steps:
 48    - id: resolve-channel
 49      name: deploy_docs::deploy_docs_job::resolve_channel_step
 50      run: |
 51        if [ -z "$CHANNEL" ]; then
 52            if [ "$GITHUB_REF" = "refs/heads/main" ]; then
 53                CHANNEL="nightly"
 54            else
 55                echo "::error::channel input is required when ref is not main."
 56                exit 1
 57            fi
 58        fi
 59
 60        case "$CHANNEL" in
 61            "nightly")
 62                SITE_URL="/docs/nightly/"
 63                PROJECT_NAME="docs-nightly"
 64                ;;
 65            "preview")
 66                SITE_URL="/docs/preview/"
 67                PROJECT_NAME="docs-preview"
 68                ;;
 69            "stable")
 70                SITE_URL="/docs/"
 71                PROJECT_NAME="docs"
 72                ;;
 73            *)
 74                echo "::error::Invalid docs channel '$CHANNEL'. Expected one of: nightly, preview, stable."
 75                exit 1
 76                ;;
 77        esac
 78
 79        echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
 80        echo "site_url=$SITE_URL" >> "$GITHUB_OUTPUT"
 81        echo "project_name=$PROJECT_NAME" >> "$GITHUB_OUTPUT"
 82      env:
 83        CHANNEL: ${ inputs.channel }
 84    - name: steps::checkout_repo
 85      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
 86      with:
 87        clean: false
 88        ref: ${{ inputs.commit_sha != '' && inputs.commit_sha || github.sha }}
 89    - name: steps::setup_cargo_config
 90      run: |
 91        mkdir -p ./../.cargo
 92        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
 93    - name: steps::cache_rust_dependencies_namespace
 94      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
 95      with:
 96        cache: rust
 97        path: ~/.rustup
 98    - name: steps::setup_linux
 99      run: ./script/linux
100    - name: steps::download_wasi_sdk
101      run: ./script/download-wasi-sdk
102    - name: ./script/generate-action-metadata
103      run: ./script/generate-action-metadata
104    - name: deploy_docs::lychee_link_check
105      uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
106      with:
107        args: --no-progress --exclude '^http' './docs/src/**/*'
108        fail: true
109        jobSummary: false
110    - name: deploy_docs::install_mdbook
111      uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08
112      with:
113        mdbook-version: 0.4.37
114    - name: deploy_docs::build_docs_book
115      run: |
116        mkdir -p target/deploy
117        mdbook build ./docs --dest-dir=../target/deploy/docs/
118    - name: deploy_docs::lychee_link_check
119      uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
120      with:
121        args: --no-progress --exclude '^http' 'target/deploy/docs'
122        fail: true
123        jobSummary: false
124    - name: deploy_docs::docs_deploy_steps::deploy_to_cf_pages
125      uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
126      with:
127        apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
128        accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
129        command: pages deploy target/deploy --project-name=${{ steps.resolve-channel.outputs.project_name }}
130    - name: deploy_docs::docs_deploy_steps::upload_install_script
131      uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
132      with:
133        apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
134        accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
135        command: r2 object put -f script/install.sh zed-open-source-website-assets/install.sh
136    - name: deploy_docs::docs_deploy_steps::deploy_docs_worker
137      uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
138      with:
139        apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
140        accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
141        command: deploy .cloudflare/docs-proxy/src/worker.js
142    - name: deploy_docs::docs_deploy_steps::upload_wrangler_logs
143      if: always()
144      uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
145      with:
146        name: wrangler_logs
147        path: /home/runner/.config/.wrangler/logs/
148    timeout-minutes: 60
149defaults:
150  run:
151    shell: bash -euxo pipefail {0}