-
Notifications
You must be signed in to change notification settings - Fork 58
45 lines (39 loc) · 1.67 KB
/
sync_notebooks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Sync Demos and docs
on:
workflow_dispatch:
push:
branches-ignore: [main]
paths:
- "examples/use_cases/**/*.ipynb"
- "examples/tutorials/*.ipynb"
jobs:
sync-notebooks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: "Copy demo & tutorial notebooks to top level .colab folder"
run: rm -rf .colab/ && mkdir -p .colab/ && cp -R examples/use_cases/* .colab/ && cp -R examples/tutorials/* .colab/
- name: "Copy tutorial notebooks to docs"
# Run sed command to make Table of Content links lowercase so they work
run: |
cp -R examples/tutorials/* docs/mkdocs/tutorials/
find docs/mkdocs/tutorials/* -type f -name "*.ipynb" -exec sed -i 's/(\#.*)/\L&/g' {} \;
- name: "Regex out the NBVAL_SKIP and NBVAL_IGNORE_OUTPUT comments"
run: |
cd .colab/
find ./ -type f -name "*.ipynb" -exec sed -i 's/\#[\ ]*NBVAL_SKIP//g' {} \;
find ./ -type f -name "*.ipynb" -exec sed -i 's/\#[\ ]*NBVAL_IGNORE_OUTPUT//g' {} \;
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "Humble bot servant"
git add docs/mkdocs/tutorials/*
git add .colab/
(git diff --quiet && git diff --staged --quiet) || git commit -m "Refresh demos folder and update docs"
- name: push synced changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}