2023-11-22 11:43:29 -08:00
# Google Cloud docs updates that run when docs, Rust code, or dependencies are modified,
2024-11-11 04:51:51 -08:00
# but only on PRs from the ZcashFoundation/zebra repository. (External PRs are deployed by GitHub's Merge Queue.)
2023-12-12 15:51:28 -08:00
# - 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.
2021-02-20 03:31:12 -08:00
name : Docs
2022-08-29 17:11:05 -07:00
# 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 :
2023-08-15 07:13:00 -07:00
group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress : true
2022-08-29 17:11:05 -07:00
2021-02-20 03:31:12 -08:00
on :
2021-03-03 13:59:01 -08:00
workflow_dispatch :
2023-11-22 11:43:29 -08:00
2021-02-20 03:31:12 -08:00
push :
2023-11-22 11:43:29 -08:00
# Skip main branch updates where docs, Rust code, and dependencies aren't modified.
2021-02-20 03:31:12 -08:00
branches :
- main
2022-02-11 06:05:19 -08:00
paths :
2022-03-02 06:23:05 -08:00
# doc source files
2022-01-25 03:58:11 -08:00
- 'book/**'
- '**/firebase.json'
2023-08-16 15:16:55 -07:00
- '**/.firebaserc'
2022-01-25 03:58:11 -08:00
- 'katex-header.html'
2022-03-02 06:23:05 -08:00
# rustdoc source files
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
2023-01-24 08:27:56 -08:00
# configuration files
- '.cargo/config.toml'
- '**/clippy.toml'
2022-03-02 06:23:05 -08:00
# workflow definitions
2023-10-17 23:16:02 -07:00
- '.github/workflows/docs-deploy-firebase.yml'
2021-02-20 03:31:12 -08:00
2023-08-15 07:13:00 -07:00
pull_request :
2023-11-22 11:43:29 -08:00
# Skip PRs where docs, Rust code, and dependencies aren't modified.
2023-08-15 07:13:00 -07:00
paths :
# doc source files
- 'book/**'
- '**/firebase.json'
2023-08-16 15:16:55 -07:00
- '**/.firebaserc'
2023-08-15 07:13:00 -07:00
- 'katex-header.html'
# rustdoc source files
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
# configuration files
- '.cargo/config.toml'
- '**/clippy.toml'
# workflow definitions
2023-12-18 13:07:40 -08:00
- '.github/workflows/docs-deploy-firebase.yml'
2023-08-15 07:13:00 -07:00
2022-08-22 20:43:18 -07:00
env :
2023-04-12 23:56:21 -07:00
RUST_LOG : ${{ vars.RUST_LOG }}
RUST_BACKTRACE : ${{ vars.RUST_BACKTRACE }}
RUST_LIB_BACKTRACE : ${{ vars.RUST_LIB_BACKTRACE }}
COLORBT_SHOW_HIDDEN : ${{ vars.COLORBT_SHOW_HIDDEN }}
2023-08-15 07:13:00 -07:00
FIREBASE_CHANNEL : ${{ github.event_name == 'pull_request' && 'preview' || 'live' }}
2023-08-17 19:04:56 -07:00
# 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
2022-08-22 20:43:18 -07:00
2023-11-22 11:43:29 -08:00
# IMPORTANT
#
2023-11-23 02:56:19 -08:00
# 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.
2021-02-20 03:31:12 -08:00
jobs :
2023-08-15 07:13:00 -07:00
build-docs-book :
name : Build and Deploy Zebra Book Docs
2024-11-11 04:51:51 -08:00
# Skip PRs from external repositories, let them pass, and then GitHub's Merge Queue will check them
2023-11-27 09:57:10 -08:00
if : ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }}
2023-08-15 07:13:00 -07:00
timeout-minutes : 5
runs-on : ubuntu-latest
permissions :
checks : write
contents : 'read'
id-token : 'write'
pull-requests : write
steps :
- name : Checkout the source code
2024-11-05 03:47:35 -08:00
uses : actions/checkout@v4.2.2
2023-08-15 07:13:00 -07:00
with :
persist-credentials : false
2024-05-17 09:39:02 -07:00
- uses : r7kamura/rust-problem-matchers@v1.5.0
2023-08-29 18:32:14 -07:00
2023-08-15 07:13:00 -07:00
- name : Setup mdBook
2024-11-05 03:47:35 -08:00
uses : jontze/action-mdbook@v3.0.1
2023-08-15 07:13:00 -07:00
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
2024-11-05 03:47:35 -08:00
uses : google-github-actions/auth@v2.1.7
2023-08-15 07:13:00 -07:00
with :
workload_identity_provider : '${{ vars.GCP_WIF }}'
service_account : '${{ vars.GCP_FIREBASE_SA }}'
2023-08-17 19:04:56 -07:00
# TODO: remove this step after issue https://github.com/FirebaseExtended/action-hosting-deploy/issues/174 is fixed
2023-08-16 15:16:55 -07:00
- name : Add $GCP_FIREBASE_SA_PATH to env
run : |
2023-08-15 07:13:00 -07:00
# shellcheck disable=SC2002
2023-08-16 15:16:55 -07:00
echo "GCP_FIREBASE_SA_PATH=$(cat ${{ steps.auth.outputs.credentials_file_path }} | tr -d '\n')" >> "$GITHUB_ENV"
2023-08-15 07:13:00 -07:00
- name : Deploy Zebra book to firebase
2024-06-04 15:41:40 -07:00
uses : FirebaseExtended/action-hosting-deploy@v0.9.0
2023-08-15 07:13:00 -07:00
with :
2023-08-16 15:16:55 -07:00
firebaseServiceAccount : ${{ env.GCP_FIREBASE_SA_PATH }}
2023-08-15 07:13:00 -07:00
channelId : ${{ env.FIREBASE_CHANNEL }}
2023-08-16 15:16:55 -07:00
projectId : ${{ vars.GCP_FIREBASE_PROJECT }}
2023-08-15 07:13:00 -07:00
target : docs-book
build-docs-internal :
name : Build and Deploy Zebra Internal Docs
2023-11-27 09:57:10 -08:00
if : ${{ !startsWith(github.event_name, 'pull') || !github.event.pull_request.head.repo.fork }}
2023-08-15 07:13:00 -07:00
timeout-minutes : 45
runs-on : ubuntu-latest
permissions :
checks : write
contents : 'read'
id-token : 'write'
pull-requests : write
steps :
- name : Checkout the source code
2024-11-05 03:47:35 -08:00
uses : actions/checkout@v4.2.2
2023-08-15 07:13:00 -07:00
with :
persist-credentials : false
2024-05-17 09:39:02 -07:00
- uses : r7kamura/rust-problem-matchers@v1.5.0
2023-08-29 18:32:14 -07:00
2023-08-15 07:13:00 -07:00
- name : Install last version of Protoc
2024-02-06 05:19:46 -08:00
uses : arduino/setup-protoc@v3.0.0
2023-08-15 07:13:00 -07:00
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
2024-10-17 06:05:30 -07:00
- uses : Swatinem/rust-cache@v2.7.5
2021-02-20 03:31:12 -08:00
2022-04-11 22:06:37 -07:00
- name : Build internal docs
run : |
2023-08-16 15:16:55 -07:00
cargo doc --no-deps --workspace --all-features --document-private-items --target-dir "$(pwd)"/target/internal
2021-02-20 03:31:12 -08:00
2023-08-15 07:13:00 -07:00
# Setup gcloud CLI
- name : Authenticate to Google Cloud
id : auth
2024-11-05 03:47:35 -08:00
uses : google-github-actions/auth@v2.1.7
2023-08-15 07:13:00 -07:00
with :
workload_identity_provider : '${{ vars.GCP_WIF }}'
service_account : '${{ vars.GCP_FIREBASE_SA }}'
2023-08-17 19:04:56 -07:00
# TODO: remove this step after issue https://github.com/FirebaseExtended/action-hosting-deploy/issues/174 is fixed
2023-08-16 15:16:55 -07:00
- name : Add $GCP_FIREBASE_SA_PATH to env
run : |
2023-08-15 07:13:00 -07:00
# shellcheck disable=SC2002
2023-08-16 15:16:55 -07:00
echo "GCP_FIREBASE_SA_PATH=$(cat ${{ steps.auth.outputs.credentials_file_path }} | tr -d '\n')" >> "$GITHUB_ENV"
2023-08-15 07:13:00 -07:00
2022-04-11 22:06:37 -07:00
- name : Deploy internal docs to firebase
2024-06-04 15:41:40 -07:00
uses : FirebaseExtended/action-hosting-deploy@v0.9.0
2022-04-11 22:06:37 -07:00
with :
2023-08-16 15:16:55 -07:00
firebaseServiceAccount : ${{ env.GCP_FIREBASE_SA_PATH }}
2023-08-15 07:13:00 -07:00
channelId : ${{ env.FIREBASE_CHANNEL }}
target : docs-internal
2023-08-16 15:16:55 -07:00
projectId : ${{ vars.GCP_FIREBASE_PROJECT }}