Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PR preview deployment logic #19

Merged
merged 10 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: build-and-deploy-book
name: publish-book

# Trigger the workflow on push to main branch and PRs
on: [push, pull_request]
# Trigger the workflow on push to main branch
on:
push:
branches:
- main
# This job installs dependencies, builds the book, and deploys the html
jobs:
build-and-deploy-book:
Expand Down Expand Up @@ -51,6 +54,7 @@ jobs:
run: |
find _build/html -name "*.log" -print -exec cat {} \;
- name: 🚀 Deploy to GitHub Pages
# redudant but keeping for testing purposes
if: github.ref == 'refs/heads/main'
uses: peaceiris/[email protected]
with:
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/trigger-book-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: trigger-book-build
on:
pull_request:

jobs:
install-dependencies:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.9]
steps:
- uses: actions/checkout@v2
- name: Get PR number
run: echo "Your PR is ${PR}"
env:
PR: ${{ github.event.pull_request.number }}
- name: 📦 Cache Conda Packages
uses: actions/cache@v2
env:
# Increase this value to reset cache if etc/example-environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('conda-linux-64.lock') }}
- name: 🐍 Set up Conda environment
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: false
activate-environment: DGM2lines
environment-file: conda-linux-64.lock
- name: 👀 Check Conda environment
shell: bash -l {0}
run: |
pip install -r requirements.txt
conda info
conda list
- name: 📦 Cache Notebooks
uses: actions/cache@v2
with:
path: _build/.jupyter_cache
key: notebook_cache-${{hashFiles('_toc.yml', '_config.yml', 'environment.yml') }}
build:
uses: ProjectPythia/cookbook-actions/.github/workflows/build-book.yaml@main
with:
environment_name: DGM2lines
artifact_name: book-zip-${{ github.event.number }}
path_to_notebooks: "src"
build_command: "jupyter-book build --keep-going ."
9 changes: 9 additions & 0 deletions .github/workflows/trigger-delete-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: trigger-delete-preview

on:
pull_request_target:
types: closed

jobs:
delete:
uses: ProjectPythia/cookbook-actions/.github/workflows/delete-preview.yaml@main
29 changes: 29 additions & 0 deletions .github/workflows/trigger-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: trigger-preview
on:
workflow_run:
workflows:
- trigger-book-build
types:
- requested
- completed
permissions:
pull-requests: write
jobs:
find-pull-request:
uses: ProjectPythia/cookbook-actions/.github/workflows/find-pull-request.yaml@main
deploy-preview:
needs: find-pull-request
if: github.event.workflow_run.conclusion == 'success'
uses: ProjectPythia/cookbook-actions/.github/workflows/deploy-book.yaml@main
with:
artifact_name: book-zip-${{ needs.find-pull-request.outputs.number }}
destination_dir: _preview/${{ needs.find-pull-request.outputs.number }} # deploy to subdirectory labeled with PR number
is_preview: 'true'
publish_dir: "src/_build/html"

preview-comment:
needs: find-pull-request
uses: ProjectPythia/cookbook-actions/.github/workflows/preview-comment.yaml@main
with:
pull_request_number: ${{ needs.find-pull-request.outputs.number }}
sha: ${{ needs.find-pull-request.outputs.sha }}
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ __pycache__
*.jpeg
*.npz
*.pth
_build/*
src/_build/*
_notebook_cache/*
notebooks/figs/symbolic_regression.png
notebooks/figs/symbolic_regression_pw.png
notebooks/Source.gv
notebooks/*.pkl
notebooks/*.csv*
notebooks/figs/symbolic_regression.svg
notebooks/figs/symbolic_regression_pw.svg
dataset*
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading