-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Build Rust docs | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
|
||
build_rust_docs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout branch | ||
uses: actions/checkout@v2 | ||
|
||
- name: Checkout gh-pages | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: gh-pages | ||
path: docs | ||
|
||
# We need to set up git user details before we can perform git operations. | ||
- name: git setup | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "GitHub Actions" | ||
# Remove all files from the docs folder. | ||
- name: clear docs folder | ||
run: rm --recursive --force "./docs/*" | ||
|
||
# Build Docker image, caching from the latest version from the remote repository. | ||
- name: Docker build | ||
run: | | ||
docker pull gcr.io/oak-ci/oak:latest | ||
docker build --pull --cache-from=gcr.io/oak-ci/oak:latest --tag=gcr.io/oak-ci/oak:latest . | ||
# Generate docs from within the Docker image. | ||
- name: cargo doc | ||
run: ./scripts/docker_run cargo doc --no-deps | ||
|
||
# Copy generated docs to docs folder, commit the results, and push to gh-pages. | ||
# This step only applies to `push` events (not `pull_request`). | ||
- name: commit and push | ||
if: github.event_name == 'push' | ||
run: | | ||
cp --recursive ./target/doc ./docs | ||
cd ./docs | ||
git add . | ||
git commit --message="Update gh-pages from $GITHUB_SHA" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ source "$SCRIPTS_DIR/common" | |
|
||
# First check if the current commit is "clean" with respect to the master branch. | ||
readonly BRANCH="$(git rev-parse --abbrev-ref HEAD)" | ||
([[ "${BRANCH}" == 'master' ]] && git diff --exit-code master && git diff --cached --exit-code master) \ | ||
|| (echo "please commit any pending changes first and run this script from the master branch"; exit 1) | ||
# ([[ "${BRANCH}" == 'master' ]] && git diff --exit-code master && git diff --cached --exit-code master) \ | ||
# || (echo "please commit any pending changes first and run this script from the master branch"; exit 1) | ||
|
||
readonly BRANCH_SHA1=$(git rev-parse --short=12 HEAD) | ||
readonly BRANCH_SUBJECT=$(git log -n 1 --format=format:%s) | ||
|
@@ -18,11 +18,9 @@ Auto-generated from commit ${BRANCH_SHA1} ("${BRANCH_SUBJECT}"). | |
END | ||
) | ||
|
||
# Create a temporary directory to stage the output of the generation process. | ||
readonly TARGET_DIR=$(mktemp --directory --tmpdir=/tmp 'project-oak-gh-pages-XXXXXXXXXX') | ||
|
||
# Clone the gh-pages branch to the target directory, limiting to one commit. | ||
git clone [email protected]:project-oak/oak.git --branch=gh-pages --depth=1 "${TARGET_DIR}" | ||
# Directory to stage the output of the generation process. This is created and populated by the | ||
# https://github.com/actions/checkout action. | ||
readonly TARGET_DIR='docs' | ||
|
||
# Remove everything from the target directory. This script is supposed to automatically recreate | ||
# everything within that directory. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters