deploy_docs.yml

  1# Generated from xtask::workflows::deploy_docs
  2# Rebuild with `cargo xtask workflows`.
  3name: deploy_docs
  4on:
  5  workflow_call:
  6    inputs:
  7      channel:
  8        description: channel
  9        type: string
 10        default: ''
 11      checkout_ref:
 12        description: checkout_ref
 13        type: string
 14        default: ''
 15    secrets:
 16      DOCS_AMPLITUDE_API_KEY:
 17        description: DOCS_AMPLITUDE_API_KEY
 18        required: true
 19      CLOUDFLARE_API_TOKEN:
 20        description: CLOUDFLARE_API_TOKEN
 21        required: true
 22      CLOUDFLARE_ACCOUNT_ID:
 23        description: CLOUDFLARE_ACCOUNT_ID
 24        required: true
 25  workflow_dispatch:
 26    inputs:
 27      channel:
 28        description: 'Docs channel to deploy: nightly, preview, or stable'
 29        type: string
 30        default: ''
 31      checkout_ref:
 32        description: Git ref to checkout and deploy. Defaults to event SHA when omitted.
 33        type: string
 34        default: ''
 35jobs:
 36  deploy_docs:
 37    if: github.repository_owner == 'zed-industries'
 38    name: Build and Deploy Docs
 39    runs-on: namespace-profile-16x32-ubuntu-2204
 40    env:
 41      DOCS_AMPLITUDE_API_KEY: ${{ secrets.DOCS_AMPLITUDE_API_KEY }}
 42    steps:
 43    - id: resolve-channel
 44      name: deploy_docs::resolve_channel_step
 45      run: |
 46        if [ -z "$CHANNEL" ]; then
 47            if [ "$GITHUB_REF" = "refs/heads/main" ]; then
 48                CHANNEL="nightly"
 49            else
 50                echo "::error::channel input is required when ref is not main."
 51                exit 1
 52            fi
 53        fi
 54
 55        case "$CHANNEL" in
 56            "nightly")
 57                SITE_URL="/docs/nightly/"
 58                PROJECT_NAME="docs-nightly"
 59                ;;
 60            "preview")
 61                SITE_URL="/docs/preview/"
 62                PROJECT_NAME="docs-preview"
 63                ;;
 64            "stable")
 65                SITE_URL="/docs/"
 66                PROJECT_NAME="docs"
 67                ;;
 68            *)
 69                echo "::error::Invalid docs channel '$CHANNEL'. Expected one of: nightly, preview, stable."
 70                exit 1
 71                ;;
 72        esac
 73
 74        {
 75            echo "channel=$CHANNEL"
 76            echo "site_url=$SITE_URL"
 77            echo "project_name=$PROJECT_NAME"
 78        } >> "$GITHUB_OUTPUT"
 79      env:
 80        CHANNEL: ${{ inputs.channel }}
 81    - name: steps::checkout_repo
 82      uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
 83      with:
 84        clean: false
 85        ref: ${{ inputs.checkout_ref != '' && inputs.checkout_ref || github.sha }}
 86    - name: steps::setup_cargo_config
 87      run: |
 88        mkdir -p ./../.cargo
 89        cp ./.cargo/ci-config.toml ./../.cargo/config.toml
 90    - name: steps::cache_rust_dependencies_namespace
 91      uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
 92      with:
 93        cache: rust
 94        path: ~/.rustup
 95    - name: steps::setup_linux
 96      run: ./script/linux
 97    - name: steps::download_wasi_sdk
 98      run: ./script/download-wasi-sdk
 99    - name: ./script/generate-action-metadata
100      run: ./script/generate-action-metadata
101    - name: deploy_docs::lychee_link_check
102      uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
103      with:
104        args: --no-progress --exclude '^http' './docs/src/**/*'
105        fail: true
106        jobSummary: false
107    - name: deploy_docs::install_mdbook
108      uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08
109      with:
110        mdbook-version: 0.4.37
111    - name: deploy_docs::build_docs_book::<alloc[d66a2b52346aa9d5]::string::String, alloc[d66a2b52346aa9d5]::string::String>
112      run: |
113        mkdir -p target/deploy
114        mdbook build ./docs --dest-dir=../target/deploy/docs/
115      env:
116        DOCS_CHANNEL: ${{ steps.resolve-channel.outputs.channel }}
117        MDBOOK_BOOK__SITE_URL: ${{ steps.resolve-channel.outputs.site_url }}
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}