Skip to content

Commit

Permalink
GH actions
Browse files Browse the repository at this point in the history
  • Loading branch information
tiziano88 committed Apr 18, 2020
1 parent 1304050 commit 9f82564
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build_rust_docs.yaml
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
12 changes: 5 additions & 7 deletions scripts/build_gh_pages
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.
Expand Down
1 change: 0 additions & 1 deletion scripts/docker_run
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ docker build \

docker_run_flags=(
'--interactive'
'--tty'
'--rm'
"--user=$DOCKER_UID:$DOCKER_GID"
"--env=USER=$DOCKER_USER"
Expand Down

0 comments on commit 9f82564

Please sign in to comment.