blob: 3e51ad7b5e6ab4e70ed488f300592e4a3b4067c6 [file] [log] [blame]
Brian Silvermancc09f182022-03-09 15:40:20 -08001#!/bin/bash
2
3set -euo pipefail
4
5if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then
6 DOCS_WORKSPACE="${BUILD_WORKSPACE_DIRECTORY}"
7else
8 # Get the directory of the current script when not running under
9 # Bazel (as indicated by the lack of BUILD_WORKSPACE_DIRECTORY).
10 DOCS_WORKSPACE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
11fi
12
13pushd "${DOCS_WORKSPACE}" &> /dev/null
14# It's important to clean the workspace so we don't end up with unintended
15# docs artifacts in the new commit.
16bazel clean \
17&& bazel build //... \
18&& cp bazel-bin/*.md . \
19&& chmod 0644 *.md
20
21if [ -n "$(git status --porcelain)" ]; then
Adam Snaider1c095c92023-07-08 02:09:58 -040022 >&2 git status
23 >&2 echo '/docs is out of date. Please run `./docs/update_docs.sh` from the root of rules_rust and push the results' >&2
Brian Silvermancc09f182022-03-09 15:40:20 -080024 exit 1
25fi
26
27popd &> /dev/null