Skip to content

Commit

Permalink
Add github action to generate and push docs to docs branch
Browse files Browse the repository at this point in the history
Instead of requiring that users regenerate auto-generated documentation
each time it changes, this adds a github action to force push any
changes on the main branch to the docs branch.  Github pages allows
docs to be on any branch, in the docs folder.
  • Loading branch information
David Freese committed Apr 19, 2021
1 parent 42a6740 commit eb8caca
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 2,757 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/gen_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Generate Documenation Pages
on:
push:
branches:
- main
jobs:
generate:
# if: ${{ github.repository_owner == 'bazelbuild' }}
name: Generate Docs
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install bazelisk
run: .github/workflows/scripts/install_bazelisk.sh
env:
USE_BAZEL_VERSION: 4.0.0
- name: Generate and Push
run: .github/workflows/scripts/publish_docs.sh
7 changes: 7 additions & 0 deletions .github/workflows/install_bazelisk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail

curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.1.0/bazelisk-linux-amd64"
mkdir -p "${GITHUB_WORKSPACE}/bin/"
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
24 changes: 24 additions & 0 deletions .github/workflows/publish_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -exuo pipefail

# run within the docs workspace
pushd docs &> /dev/null

# We use a bazelisk-installed bazel
"${GITHUB_WORKSPACE}/bin/bazel" clean
"${GITHUB_WORKSPACE}/bin/bazel" build //...

# Pull out the relevant docs
cp bazel-bin/*.md .
chmod 0644 *.md

# And generate a new commit, that we push to the "docs" branch.
git config user.name github-actions
git config user.email github-actions@github.com
git add *.md
git commit -m "Regenerate documentation"
git remote -v
git push -f origin HEAD:docs

popd &> /dev/null

86 changes: 0 additions & 86 deletions docs/cargo_build_script.md

This file was deleted.

Loading

0 comments on commit eb8caca

Please sign in to comment.