Skip to content

Commit

Permalink
Add temporary docs for PRs (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-naumann authored Dec 22, 2024
1 parent 63c387a commit 27f3ba5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 24 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Continuous Deployment

on:
push:
branches: [ main ]

jobs:
deploy-docs:
runs-on: ubuntu-latest
concurrency: deploy-${{ github.ref }}
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.10"

- name: Set up env
run: uv sync --all-extras --frozen

- name: Copy notebooks to docs folder
run: cp -r notebooks/* docs/notebooks

- run: |
uv run ipython kernel install --user --name=behavior_generation_lecture
uv run mkdocs gh-deploy --force
51 changes: 27 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Continuous Integration and Deployment
name: Continuous Integration

on:
push:
branches: [ main ]
Expand All @@ -7,8 +8,11 @@ on:
- cron: "0 3 * * 1" # Run every Monday 3 am

jobs:
test:
ci:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4

Expand All @@ -21,7 +25,7 @@ jobs:
run: sudo apt install python3-tk -y

- name: Set up env
run: uv sync --all-extras
run: uv sync --all-extras --frozen

- name: Run ruff format
run: uv run ruff format
Expand All @@ -47,32 +51,31 @@ jobs:
- name: Copy notebooks to docs folder
run: cp -r notebooks/* docs/notebooks

- name: Build docs
- name: Build PR docs (including running the notebooks)
run: |
sed -i "s/^site_name:.*$/site_name: 'Behavior Generation Lecture - tmp docs for PR ${{ github.event.pull_request.number }}'/" mkdocs.yml
uv run ipython kernel install --user --name=behavior_generation_lecture
uv run mkdocs build
uv run mkdocs build --site-dir site/pr-${{ github.event.pull_request.number }}
deploy-pages:
runs-on: ubuntu-latest
needs: [test]
if: github.ref == 'refs/heads/main'
concurrency: deploy-${{ github.ref }}
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Deploy PR docs
if: github.event_name == 'pull_request'
uses: peaceiris/actions-gh-pages@v4
with:
version: "0.5.10"
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: site/pr-${{ github.event.pull_request.number }}
destination_dir: pr-${{ github.event.pull_request.number }} # Deploy to subdirectory
publish_branch: gh-pages
keep_files: true # Retain other content on gh-pages

- name: Add PR note
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
### :books: Docs
- name: Set up env
run: uv sync --all-extras
Created [temporary docs](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-${{ github.event.pull_request.number }}/).
- name: Copy notebooks to docs folder
run: cp -r notebooks/* docs/notebooks

- run: |
uv run ipython kernel install --user --name=behavior_generation_lecture
uv run mkdocs gh-deploy --force
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ nav:
- Decision Making:
- Value Iteration: notebooks/mdp_value_iteration.ipynb
- Q-Learning: notebooks/mdp_q_learning.ipynb
- Policy Gradient: notebooks/mdp_policy_gradient.ipynb
- API Documentation (partial): reference/

plugins:
Expand Down

0 comments on commit 27f3ba5

Please sign in to comment.