generated from 2i2c-org/hub-user-image-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Preview | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Build and push container image"] | ||
branches: [postprint] | ||
types: | ||
- completed | ||
|
||
# This job installs dependencies, build the jupyter notebook, and pushes it to `render`, a new `branch` | ||
jobs: | ||
build: | ||
name: ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
|
||
if: github.repository_owner == 'eds-book-gallery' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["ubuntu-latest"] | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: postprint | ||
# Set notebook name | ||
- name: Get properties from the config file | ||
id: config_file | ||
uses: notiz-dev/github-action-json-property@release | ||
with: | ||
path: '.github/config.json' | ||
prop_path: 'notebook_name' | ||
# Set quay image | ||
- name: Get properties from the config file | ||
id: config_quay | ||
uses: notiz-dev/github-action-json-property@release | ||
with: | ||
path: '.github/config.json' | ||
prop_path: 'quay_image' | ||
# Set kernel name | ||
- name: Get properties from the config file | ||
id: config_kernel | ||
uses: notiz-dev/github-action-json-property@release | ||
with: | ||
path: '.github/config.json' | ||
prop_path: 'kernel' | ||
# Render the notebook | ||
- name: Run the build process with Docker | ||
uses: addnab/docker-run-action@v3 | ||
with: | ||
image: quay.io/${{steps.config_quay.outputs.prop}}:latest | ||
options: --user root -v ${{ github.workspace }}:/tmp | ||
shell: bash | ||
run: | | ||
v=$(jupyter kernelspec list | awk '{print $1}' | egrep ${{steps.config_kernel.outputs.prop}}) | ||
jupyter-nbconvert --to notebook --ExecutePreprocessor.kernel_name="$v" --inplace --execute ${{steps.config_file.outputs.prop}} | ||
cp ${{steps.config_file.outputs.prop}} /tmp | ||
- name: Commit | ||
run: | | ||
ls | ||
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git rm \* ':!${{steps.config_file.outputs.prop}}' | ||
git add ${{steps.config_file.outputs.prop}} | ||
git commit -m 'update' | ||
- name: Push | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: preview | ||
force: true |