Skip to content

Commit

Permalink
switch to gh page
Browse files Browse the repository at this point in the history
  • Loading branch information
TimotheeMathieu committed Apr 24, 2024
1 parent 5a60c15 commit 9457fbf
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 5 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/doc_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: documentation_dev
on:
pull_request_target:
branches:
- main
types: [closed]
push:
branches:
- main


permissions:
contents: write

jobs:
docs:
runs-on: ubuntu-latest
steps:
- name: Wait for version update
run: |
sleep 60
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install dependencies
run: |
pip install .
- name: Sphinx build
run: |
poetry run sphinx-build docs _build
- uses: actions/checkout@v4
with:
# This is necessary so that we have the tags.
fetch-depth: 0
ref: gh-pages
path: gh_pages
- name: copy stable and preview version changes
run: |
cp -rv gh_pages/preview_pr _build/preview_pr || echo "Ignoring exit status"
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _build/
force_orphan: true
115 changes: 115 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: "preview"

on:
workflow_run:
workflows: ["ready_for_review"]
types:
- completed

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
docs:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download workflow artifact
uses: dawidd6/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: peek_icons.yml
run_id: ${{ github.event.workflow_run.id }}

- name: Read the pr_num file
id: pr_num_reader
uses: juliangruber/[email protected]
with:
path: ./pr_num/pr_num.txt

- name: Checkout
uses: actions/checkout@v4
with:
path: main
- name: Checkout Pull Request
env:
GITHUB_USER: ${{ secrets.GITHUB_USER }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd main
gh pr checkout ${{ steps.pr_num_reader.outputs.content }}
cd ..
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install dependencies and build doc
run: |
set +e
cd main
curl -C - https://raw.githubusercontent.com/rlberry-py/rlberry/main/pyproject.toml > pyproject.toml
poetry install --all-extras --with dev --sync
poetry run sphinx-build docs ../_build
echo "exitcode=$?" >> $GITHUB_ENV
cd ..
- uses: actions/checkout@v4
with:
# This is necessary so that we have the tags.
fetch-depth: 0
ref: gh-pages
path: gh_pages

- name: Commit documentation changes
if: ${{ env.exitcode == 0 }}
run: |
cd gh_pages
rm -r preview_pr || echo "Ignoring exit status"
mkdir preview_pr
cp -rv ../_build/* preview_pr
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Preview documentation"
git push
- name: Comment on the PR about the result
uses: jungwinter/comment@v1 # let us comment on a specific PR
if: ${{ env.exitcode == 0 }}
env:
MESSAGE: |
Hello,
The build of the doc succeeded. The documentation preview is available here:
https://rlberry-py.github.io/rlberry/preview_pr
with:
type: create
issue_number: ${{ steps.pr_num_reader.outputs.content }}
token: ${{ secrets.GITHUB_TOKEN }}
body: >
${{ format(env.MESSAGE,
fromJSON(steps.icons_overview_img_step.outputs.markdown_urls)[0],
join(fromJSON(steps.icons_detailed_img_step.outputs.markdown_urls), '')) }}
- name: Comment on the PR about the result, fail
uses: jungwinter/comment@v1 # let us comment on a specific PR
if: ${{ env.exitcode != 0 }}
env:
MESSAGE: |
Hello,
The build of the doc failed. Look up the reason here:
https://github.com/rlberry-py/rlberry/actions/workflows/preview.yml
with:
type: create
issue_number: ${{ steps.pr_num_reader.outputs.content }}
token: ${{ secrets.GITHUB_TOKEN }}
body: >
${{ format(env.MESSAGE,
fromJSON(steps.icons_overview_img_step.outputs.markdown_urls)[0],
join(fromJSON(steps.icons_detailed_img_step.outputs.markdown_urls), '')) }}
- name: Exit
run: exit "$exitcode"
26 changes: 26 additions & 0 deletions .github/workflows/ready_for_review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: ready_for_review

on:
pull_request:
types: [labeled, opened, reopened, synchronize]

jobs:
build:
if: contains( github.event.pull_request.labels.*.name, 'ready for review')
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Run a one-line script
run: echo ready for review!
- name: Save the PR number in an artifact
shell: bash
env:
PR_NUM: ${{ github.event.number }}
run: echo $PR_NUM > pr_num.txt

- name: Upload the PR number
uses: actions/upload-artifact@v2
with:
name: pr_num
path: ./pr_num.txt
6 changes: 3 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. _api:

###########
rlberry API
###########
#################
rlberry-scool API
#################


Manager
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
copyright = "2023, rlberry team"
author = "rlberry team"


ver_file = os.path.join("../rlberry_scool", "_version.py")
with open(ver_file) as f:
exec(f.read())
Expand Down
1 change: 0 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ git+https://github.com/sphinx-contrib/video
matplotlib
nbsphinx
sphinx-tabs
rlberry

0 comments on commit 9457fbf

Please sign in to comment.