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      MDBOOK_BOOK__SITE_URL: ${{ steps.resolve-channel.outputs.site_url }}
 43      DOCS_CHANNEL: ${{ steps.resolve-channel.outputs.channel }}
 44    steps:
 45    - id: resolve-channel
 46      name: deploy_docs::resolve_channel_step
 47      run: |
 48        if [ -z "$CHANNEL" ]; then
 49            if [ "$GITHUB_REF" = "refs/heads/main" ]; then
 50                CHANNEL="nightly"
 51            else
 52                echo "::error::channel input is required when ref is not main."
 53                exit 1
 54            fi
 55        fi
 56
 57        case "$CHANNEL" in
 58            "nightly")
 59                SITE_URL="/docs/nightly/"
 60                PROJECT_NAME="docs-nightly"
 61                ;;
 62            "preview")
 63                SITE_URL="/docs/preview/"
 64                PROJECT_NAME="docs-preview"
 65                ;;
 66            "stable")
 67                SITE_URL="/docs/"
 68                PROJECT_NAME="docs"
 69                ;;
 70            *)
 71                echo "::error::Invalid docs channel '$CHANNEL'. Expected one of: nightly, preview, stable."
 72                exit 1
 73                ;;
 74        esac
 75
 76        echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
 77        echo "site_url=$SITE_URL" >> "$GITHUB_OUTPUT"
 78        echo "project_name=$PROJECT_NAME" >> "$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
112      run: |
113        mkdir -p target/deploy
114        mdbook build ./docs --dest-dir=../target/deploy/docs/
115    - name: deploy_docs::lychee_link_check
116      uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
117      with:
118        args: --no-progress --exclude '^http' 'target/deploy/docs'
119        fail: true
120        jobSummary: false
121    - name: deploy_docs::docs_deploy_steps::deploy_to_cf_pages
122      uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
123      with:
124        apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
125        accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
126        command: pages deploy target/deploy --project-name=${{ steps.resolve-channel.outputs.project_name }}
127    - name: deploy_docs::docs_deploy_steps::upload_install_script
128      uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
129      with:
130        apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
131        accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
132        command: r2 object put -f script/install.sh zed-open-source-website-assets/install.sh
133    - name: deploy_docs::docs_deploy_steps::deploy_docs_worker
134      uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
135      with:
136        apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
137        accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
138        command: deploy .cloudflare/docs-proxy/src/worker.js
139    - name: deploy_docs::docs_deploy_steps::upload_wrangler_logs
140      if: always()
141      uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
142      with:
143        name: wrangler_logs
144        path: /home/runner/.config/.wrangler/logs/
145    timeout-minutes: 60
146defaults:
147  run:
148    shell: bash -euxo pipefail {0}