From a0407b6e3f80ad4e4b0ea0c5adde8e648d9d5158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20=C2=A9?= Date: Mon, 21 Aug 2023 17:45:52 +0100 Subject: [PATCH] add preview workflow --- .github/workflows/preview.yaml | 73 ++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/preview.yaml diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml new file mode 100644 index 0000000..553e01f --- /dev/null +++ b/.github/workflows/preview.yaml @@ -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