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@11bd71901bbe5b1630ceea73d27597364c9af683
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@v1
81 with:
82 cache: rust
83 path: ~/.rustup
84 - name: steps::setup_linux
85 run: ./script/linux
86 - name: steps::install_mold
87 run: ./script/install-mold
88 - name: steps::download_wasi_sdk
89 run: ./script/download-wasi-sdk
90 - name: ./script/generate-action-metadata
91 run: ./script/generate-action-metadata
92 - name: deploy_docs::lychee_link_check
93 uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
94 with:
95 args: --no-progress --exclude '^http' './docs/src/**/*'
96 fail: true
97 jobSummary: false
98 - name: deploy_docs::install_mdbook
99 uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08
100 with:
101 mdbook-version: 0.4.37
102 - name: deploy_docs::build_docs_book
103 run: |
104 mkdir -p target/deploy
105 mdbook build ./docs --dest-dir=../target/deploy/docs/
106 - name: deploy_docs::lychee_link_check
107 uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
108 with:
109 args: --no-progress --exclude '^http' 'target/deploy/docs'
110 fail: true
111 jobSummary: false
112 - name: deploy_docs::pages_deploy_step
113 uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
114 with:
115 apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
116 accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
117 command: pages deploy target/deploy --project-name=${{ steps.resolve-channel.outputs.project_name }}
118 - name: deploy_docs::deploy_install_script
119 uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
120 with:
121 apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
122 accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
123 command: r2 object put -f script/install.sh zed-open-source-website-assets/install.sh
124 - name: deploy_docs::deploy_docs_worker
125 uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
126 with:
127 apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
128 accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
129 command: deploy .cloudflare/docs-proxy/src/worker.js
130 - name: deploy_docs::upload_wrangler_logs
131 if: always()
132 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
133 with:
134 name: wrangler_logs
135 path: /home/runner/.config/.wrangler/logs/
136 timeout-minutes: 60
137defaults:
138 run:
139 shell: bash -euxo pipefail {0}