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