-
Notifications
You must be signed in to change notification settings - Fork 106
184 lines (161 loc) · 6.63 KB
/
docs-deploy-firebase.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Google Cloud docs updates that run when docs, Rust code, or dependencies are modified,
# but only on PRs from the ZcashFoundation/zebra repository. (External PRs are deployed by mergify.)
# - Builds and deploys Zebra Book Docs using mdBook, setting up necessary tools and deploying to Firebase.
# - Compiles and deploys external documentation, setting up Rust with the beta toolchain and default profile, building the docs, and deploying them to Firebase.
# - Assembles and deploys internal documentation with similar steps, including private items in the documentation, and deploys to Firebase.
name: Docs
# Ensures that only one workflow task will run at a time. Previous deployments, if
# already in process, won't get cancelled. Instead, we let the first to complete
# then queue the latest pending workflow, cancelling any workflows in between
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
# Skip main branch updates where docs, Rust code, and dependencies aren't modified.
branches:
- main
paths:
# doc source files
- 'book/**'
- '**/firebase.json'
- '**/.firebaserc'
- 'katex-header.html'
# rustdoc source files
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
# configuration files
- '.cargo/config.toml'
- '**/clippy.toml'
# workflow definitions
- '.github/workflows/docs-deploy-firebase.yml'
pull_request:
# Skip PRs where docs, Rust code, and dependencies aren't modified.
paths:
# doc source files
- 'book/**'
- '**/firebase.json'
- '**/.firebaserc'
- 'katex-header.html'
# rustdoc source files
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
# configuration files
- '.cargo/config.toml'
- '**/clippy.toml'
# workflow definitions
- '.github/workflows/docs-deploy-firebase.yml'
env:
RUST_LOG: ${{ vars.RUST_LOG }}
RUST_BACKTRACE: ${{ vars.RUST_BACKTRACE }}
RUST_LIB_BACKTRACE: ${{ vars.RUST_LIB_BACKTRACE }}
COLORBT_SHOW_HIDDEN: ${{ vars.COLORBT_SHOW_HIDDEN }}
FIREBASE_CHANNEL: ${{ github.event_name == 'pull_request' && 'preview' || 'live' }}
# cargo doc doesn't support '-- -D warnings', so we have to add it here
# https://github.com/rust-lang/cargo/issues/8424#issuecomment-774662296
#
# The -A and -W settings must be the same as the `rustdocflags` in:
# https://github.com/ZcashFoundation/zebra/blob/main/.cargo/config.toml#L87
RUSTDOCFLAGS: --html-in-header katex-header.html -D warnings -A rustdoc::private_intra_doc_links
# IMPORTANT
#
# The job names in `docs-deploy-firebase.yml`, `docs-deploy-firebase.patch.yml` and
# `docs-deploy-firebase.patch-external.yml` must be kept in sync.
jobs:
build-docs-book:
name: Build and Deploy Zebra Book Docs
# Skip PRs from external repositories, let them pass, and then Mergify will check them
if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }}
timeout-minutes: 5
runs-on: ubuntu-latest
permissions:
checks: write
contents: 'read'
id-token: 'write'
pull-requests: write
steps:
- name: Checkout the source code
uses: actions/[email protected]
with:
persist-credentials: false
- uses: r7kamura/[email protected]
- name: Setup mdBook
uses: jontze/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
mdbook-version: '~0.4'
use-linkcheck: true
use-mermaid: true
- name: Build Zebra book
run: |
mdbook build book --dest-dir "$(pwd)"/target/book
# Setup gcloud CLI
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/[email protected]
with:
workload_identity_provider: '${{ vars.GCP_WIF }}'
service_account: '${{ vars.GCP_FIREBASE_SA }}'
# TODO: remove this step after issue https://github.com/FirebaseExtended/action-hosting-deploy/issues/174 is fixed
- name: Add $GCP_FIREBASE_SA_PATH to env
run: |
# shellcheck disable=SC2002
echo "GCP_FIREBASE_SA_PATH=$(cat ${{ steps.auth.outputs.credentials_file_path }} | tr -d '\n')" >> "$GITHUB_ENV"
- name: Deploy Zebra book to firebase
uses: FirebaseExtended/[email protected]
with:
firebaseServiceAccount: ${{ env.GCP_FIREBASE_SA_PATH }}
channelId: ${{ env.FIREBASE_CHANNEL }}
projectId: ${{ vars.GCP_FIREBASE_PROJECT }}
target: docs-book
build-docs-internal:
name: Build and Deploy Zebra Internal Docs
if: ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }}
timeout-minutes: 45
runs-on: ubuntu-latest
permissions:
checks: write
contents: 'read'
id-token: 'write'
pull-requests: write
steps:
- name: Checkout the source code
uses: actions/[email protected]
with:
persist-credentials: false
- uses: r7kamura/[email protected]
- name: Install last version of Protoc
uses: arduino/[email protected]
with:
version: '23.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Setup Rust with beta toolchain and default profile (to include rust-docs)
- name: Setup Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=beta --profile=default
- uses: Swatinem/[email protected]
- name: Build internal docs
run: |
cargo doc --no-deps --workspace --all-features --document-private-items --target-dir "$(pwd)"/target/internal
# Setup gcloud CLI
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/[email protected]
with:
workload_identity_provider: '${{ vars.GCP_WIF }}'
service_account: '${{ vars.GCP_FIREBASE_SA }}'
# TODO: remove this step after issue https://github.com/FirebaseExtended/action-hosting-deploy/issues/174 is fixed
- name: Add $GCP_FIREBASE_SA_PATH to env
run: |
# shellcheck disable=SC2002
echo "GCP_FIREBASE_SA_PATH=$(cat ${{ steps.auth.outputs.credentials_file_path }} | tr -d '\n')" >> "$GITHUB_ENV"
- name: Deploy internal docs to firebase
uses: FirebaseExtended/[email protected]
with:
firebaseServiceAccount: ${{ env.GCP_FIREBASE_SA_PATH }}
channelId: ${{ env.FIREBASE_CHANNEL }}
target: docs-internal
projectId: ${{ vars.GCP_FIREBASE_PROJECT }}