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 CHANNEL="${{ inputs.channel }}"
52
53 if [ -z "$CHANNEL" ]; then
54 if [ "${{ github.ref }}" = "refs/heads/main" ]; then
55 CHANNEL="nightly"
56 else
57 echo "::error::channel input is required when ref is not main."
58 exit 1
59 fi
60 fi
61
62 case "$CHANNEL" in
63 "nightly")
64 SITE_URL="/docs/nightly/"
65 PROJECT_NAME="docs-nightly"
66 ;;
67 "preview")
68 SITE_URL="/docs/preview/"
69 PROJECT_NAME="docs-preview"
70 ;;
71 "stable")
72 SITE_URL="/docs/"
73 PROJECT_NAME="docs"
74 ;;
75 *)
76 echo "::error::Invalid docs channel '$CHANNEL'. Expected one of: nightly, preview, stable."
77 exit 1
78 ;;
79 esac
80
81 echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
82 echo "site_url=$SITE_URL" >> "$GITHUB_OUTPUT"
83 echo "project_name=$PROJECT_NAME" >> "$GITHUB_OUTPUT"
84 - name: steps::checkout_repo
85 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
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@v1
95 with:
96 cache: rust
97 path: ~/.rustup
98 - name: steps::setup_linux
99 run: ./script/linux
100 - name: steps::install_mold
101 run: ./script/install-mold
102 - name: steps::download_wasi_sdk
103 run: ./script/download-wasi-sdk
104 - name: ./script/generate-action-metadata
105 run: ./script/generate-action-metadata
106 - name: deploy_docs::lychee_link_check
107 uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
108 with:
109 args: --no-progress --exclude '^http' './docs/src/**/*'
110 fail: true
111 jobSummary: false
112 - name: deploy_docs::install_mdbook
113 uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08
114 with:
115 mdbook-version: 0.4.37
116 - name: deploy_docs::build_docs_book
117 run: |
118 mkdir -p target/deploy
119 mdbook build ./docs --dest-dir=../target/deploy/docs/
120 - name: deploy_docs::lychee_link_check
121 uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
122 with:
123 args: --no-progress --exclude '^http' 'target/deploy/docs'
124 fail: true
125 jobSummary: false
126 - name: deploy_docs::docs_deploy_steps::deploy_to_cf_pages
127 uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
128 with:
129 apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
130 accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
131 command: pages deploy target/deploy --project-name=${{ steps.resolve-channel.outputs.project_name }}
132 - name: deploy_docs::docs_deploy_steps::upload_install_script
133 uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
134 with:
135 apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
136 accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
137 command: r2 object put -f script/install.sh zed-open-source-website-assets/install.sh
138 - name: deploy_docs::docs_deploy_steps::deploy_docs_worker
139 uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65
140 with:
141 apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
142 accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
143 command: deploy .cloudflare/docs-proxy/src/worker.js
144 - name: deploy_docs::docs_deploy_steps::upload_wrangler_logs
145 if: always()
146 uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
147 with:
148 name: wrangler_logs
149 path: /home/runner/.config/.wrangler/logs/
150 timeout-minutes: 60
151defaults:
152 run:
153 shell: bash -euxo pipefail {0}