Build and deploy BEHAVIOR website #7558
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
name: Build and deploy BEHAVIOR website | |
on: | |
schedule: | |
- cron: "0 * * * *" # Every hour | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
jobs: | |
build-omnigibson-docs: | |
runs-on: [self-hosted, linux] | |
strategy: | |
matrix: | |
branch: [main, og-develop] | |
defaults: | |
run: | |
shell: micromamba run -n omnigibson /bin/bash -leo pipefail {0} | |
steps: | |
- name: Fix home | |
run: echo "HOME=/root" >> $GITHUB_ENV | |
- name: Checkout source | |
uses: actions/checkout@v3 | |
with: | |
repository: StanfordVL/OmniGibson | |
ref: ${{ matrix.branch }} | |
submodules: true | |
path: omnigibson-src | |
- name: Install | |
working-directory: omnigibson-src | |
run: pip install -e . | |
- name: Install dev requirements | |
working-directory: omnigibson-src | |
run: pip install -r requirements-dev.txt | |
- name: Build docs | |
working-directory: omnigibson-src | |
run: source scripts/build_docs.sh | |
- name: Zip artifact for deployment | |
working-directory: omnigibson-src/site | |
run: apt update && apt install -y zip && zip -r ${GITHUB_WORKSPACE}/omnigibson-docs-${{ matrix.branch }}.zip * | |
- name: Deploy artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: omnigibson-docs-${{ matrix.branch }} | |
path: omnigibson-docs-${{ matrix.branch }}.zip | |
build-knowledgebase: | |
runs-on: [self-hosted, linux] | |
steps: | |
# Checkout all repos | |
- name: Checkout website repo | |
uses: actions/checkout@v3 | |
with: | |
path: website | |
- name: Clone BDDL Repo | |
uses: actions/checkout@v3 | |
with: | |
repository: StanfordVL/bddl | |
path: bddl | |
ref: develop | |
- name: Setup python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
architecture: x64 | |
# See if we need to rebuild the whole thing | |
- name: Get BDDL hash | |
id: bddl-hash | |
working-directory: bddl | |
run: echo hash=$(git rev-parse HEAD) >> "$GITHUB_OUTPUT" | |
- name: Get website hash | |
id: website-hash | |
working-directory: website | |
run: echo hash=$(git rev-parse HEAD) >> "$GITHUB_OUTPUT" | |
- name: Check cache for overall data | |
id: cache-knowledgebase | |
uses: actions/cache@v3 | |
with: | |
key: knowledgebase-${{ steps.website-hash.outputs.hash }}-${{ steps.bddl-hash.outputs.hash }} | |
path: README.md | |
lookup-only: true | |
# Rebuild if necessary | |
- if: ${{ steps.cache-knowledgebase.outputs.cache-hit != 'true' }} | |
name: Install BDDL | |
working-directory: bddl | |
run: pip install -e . | |
- if: ${{ steps.cache-knowledgebase.outputs.cache-hit != 'true' }} | |
name: Install other dependencies | |
working-directory: website/knowledgebase | |
run: pip install -r requirements.txt | |
- if: ${{ steps.cache-knowledgebase.outputs.cache-hit != 'true' }} | |
name: Start local server | |
working-directory: website/knowledgebase | |
run: flask --app knowledgebase.app run & | |
- if: ${{ steps.cache-knowledgebase.outputs.cache-hit != 'true' }} | |
name: Wait for server to come alive | |
working-directory: website/knowledgebase | |
run: curl --head -X GET --retry 20 --retry-connrefused --retry-delay 5 http://localhost:5000/knowledgebase/ | |
- if: ${{ steps.cache-knowledgebase.outputs.cache-hit != 'true' }} | |
name: Freeze static files | |
working-directory: website/knowledgebase | |
run: wget -mpEk http://localhost:5000/knowledgebase/ | |
- name: Kill local server | |
if: success() || failure() | |
run: kill $(lsof -t -i:5000) || true | |
- name: Zip artifact for deployment | |
working-directory: website/knowledgebase/localhost:5000/knowledgebase | |
run: zip -r ${GITHUB_WORKSPACE}/knowledgebase.zip * | |
- if: ${{ steps.cache-knowledgebase.outputs.cache-hit != 'true' }} | |
name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: knowledgebase | |
path: knowledgebase.zip | |
build-jekyll: | |
runs-on: [self-hosted, linux] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 | |
with: | |
working-directory: jekyll | |
ruby-version: '3.1' # Not needed with a .ruby-version file | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
cache-version: 0 # Increment this number if you need to re-download cached gems | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v3 | |
- name: Build with Jekyll | |
# Outputs to the './_site' directory by default | |
working-directory: jekyll | |
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" | |
env: | |
JEKYLL_ENV: production | |
- name: Zip artifact for deployment | |
working-directory: jekyll/_site | |
run: zip -r ${GITHUB_WORKSPACE}/jekyll.zip * | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: jekyll | |
path: jekyll.zip | |
# Combine different artifacts into a single github pages artifact | |
combine-artifacts: | |
runs-on: [self-hosted, linux] | |
needs: [build-omnigibson-docs, build-knowledgebase, build-jekyll] | |
steps: | |
- name: Pull jekyll | |
uses: actions/download-artifact@v3 | |
with: | |
name: jekyll | |
path: . | |
- name: Pull main docs | |
uses: actions/download-artifact@v3 | |
with: | |
name: omnigibson-docs-main | |
path: . | |
- name: Pull og-develop docs | |
uses: actions/download-artifact@v3 | |
with: | |
name: omnigibson-docs-og-develop | |
path: . | |
- name: Pull knowledgebase | |
uses: actions/download-artifact@v3 | |
with: | |
name: knowledgebase | |
path: . | |
- name: Unpack everything | |
run: > | |
unzip jekyll.zip -d _site && | |
unzip omnigibson-docs-main.zip -d _site/omnigibson && | |
unzip omnigibson-docs-og-develop.zip -d _site/omnigibson-develop && | |
unzip knowledgebase.zip -d _site/knowledgebase | |
- name: Upload pages artifact | |
uses: actions/upload-pages-artifact@v2 | |
# Deploy on github pages | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: [self-hosted, linux] | |
needs: combine-artifacts | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 |