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 CC: clang
43 CXX: clang++
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 {
77 echo "channel=$CHANNEL"
78 echo "site_url=$SITE_URL"
79 echo "project_name=$PROJECT_NAME"
80 } >> "$GITHUB_OUTPUT"
81 env:
82 CHANNEL: ${{ inputs.channel }}
83 - name: steps::checkout_repo
84 uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
85 with:
86 clean: false
87 ref: ${{ inputs.checkout_ref != '' && inputs.checkout_ref || github.sha }}
88 - name: steps::setup_cargo_config
89 run: |
90 mkdir -p ./../.cargo
91 cp ./.cargo/ci-config.toml ./../.cargo/config.toml
92 - name: steps::cache_rust_dependencies_namespace
93 uses: namespacelabs/nscloud-cache-action@a90bb5d4b27522ce881c6e98eebd7d7e6d1653f9
94 with:
95 cache: rust
96 path: ~/.rustup
97 - name: steps::setup_linux
98 run: ./script/linux
99 - name: steps::download_wasi_sdk
100 run: ./script/download-wasi-sdk
101 - name: ./script/generate-action-metadata
102 run: ./script/generate-action-metadata
103 - name: deploy_docs::lychee_link_check
104 uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332
105 with:
106 args: --no-progress --exclude '^http' './docs/src/**/*'
107 fail: true
108 jobSummary: false
109 - name: deploy_docs::install_mdbook
110 uses: peaceiris/actions-mdbook@ee69d230fe19748b7abf22df32acaa93833fad08
111 with:
112 mdbook-version: 0.4.37
113 - name: deploy_docs::build_docs_book
114 run: |
115 mkdir -p target/deploy
116 mdbook build ./docs --dest-dir=../target/deploy/docs/
117 env:
118 DOCS_CHANNEL: ${{ steps.resolve-channel.outputs.channel }}
119 MDBOOK_BOOK__SITE_URL: ${{ steps.resolve-channel.outputs.site_url }}
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 }} --branch main
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}