blob: f6677b9e4ffdb43cb4e8f0b9e334f368602a78f8 [file] [log] [blame]
#!/bin/bash
set -euo pipefail
if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then
DOCS_WORKSPACE="${BUILD_WORKSPACE_DIRECTORY}"
else
# Get the directory of the current script when not running under
# Bazel (as indicated by the lack of BUILD_WORKSPACE_DIRECTORY).
DOCS_WORKSPACE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
fi
pushd "${DOCS_WORKSPACE}" &> /dev/null
# It's important to clean the workspace so we don't end up with unintended
# docs artifacts in the new commit.
bazel clean \
&& bazel build //... \
&& cp bazel-bin/*.md . \
&& chmod 0644 *.md
if [ -n "$(git status --porcelain)" ]; then
git status
echo '/docs is out of date. Please run `./docs/update_docs.sh` from the root of rules_rust and push the results' >&2
exit 1
fi
popd &> /dev/null