render #71
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: render | |
on: | |
workflow_run: | |
workflows: ["Build and push container image"] | |
branches: main | |
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 | |
# 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: render | |
force: true |