1*d4726bddSHONG Yifan#!/bin/bash 2*d4726bddSHONG Yifan 3*d4726bddSHONG Yifanset -euo pipefail 4*d4726bddSHONG Yifan 5*d4726bddSHONG Yifanif [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then 6*d4726bddSHONG Yifan DOCS_WORKSPACE="${BUILD_WORKSPACE_DIRECTORY}" 7*d4726bddSHONG Yifanelse 8*d4726bddSHONG Yifan # Get the directory of the current script when not running under 9*d4726bddSHONG Yifan # Bazel (as indicated by the lack of BUILD_WORKSPACE_DIRECTORY). 10*d4726bddSHONG Yifan DOCS_WORKSPACE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" 11*d4726bddSHONG Yifanfi 12*d4726bddSHONG Yifan 13*d4726bddSHONG Yifanpushd "${DOCS_WORKSPACE}" &> /dev/null 14*d4726bddSHONG Yifan# It's important to clean the workspace so we don't end up with unintended 15*d4726bddSHONG Yifan# docs artifacts in the new commit. 16*d4726bddSHONG Yifanbazel clean \ 17*d4726bddSHONG Yifan&& bazel build //... \ 18*d4726bddSHONG Yifan&& cp bazel-bin/*.md . \ 19*d4726bddSHONG Yifan&& chmod 0644 *.md 20*d4726bddSHONG Yifan 21*d4726bddSHONG Yifanif [ -n "$(git status --porcelain)" ]; then 22*d4726bddSHONG Yifan >&2 git status 23*d4726bddSHONG Yifan >&2 echo '/docs is out of date. Please run `./docs/update_docs.sh` from the root of rules_rust and push the results' >&2 24*d4726bddSHONG Yifan exit 1 25*d4726bddSHONG Yifanfi 26*d4726bddSHONG Yifan 27*d4726bddSHONG Yifanpopd &> /dev/null 28