Skip to content

Creating html files from all notebooks #5

Creating html files from all notebooks

Creating html files from all notebooks #5

name: Creating new html files from notebooks
run-name: Creating html files from all notebooks
on:
#push:
# paths: "**.ipynb"
# Trigger on PRs that change the notebooks in some way
pull_request:
branches: [main]
paths: "**.ipynb"
#pull_request_review:
#types: [submitted]
jobs:
approved:
runs-on: ubuntu-latest
steps:
- run: echo "This PR was approved"
- name: Check out repository code
uses: actions/checkout@v4
with:
#Only checkout the branch that is being merged into main
ref: ${{ github.head_ref }}
- name: Getting only the changed Notebooks
# Gets only the changed files using an action from the marketplace
uses: Ana06/[email protected]
id: changes
- name: Running all changed Jupyter Notebooks and saving as HTML
#Makes the list of changed files into only the list of changed notebooks, then runs and converts all notebooks
run: |
notebooks=()
for changed_file in ${{ steps.changes.outputs.added_modified }}; do
if [[ "$changed_file" == *".ipynb" ]]; then
notebooks+=("$changed_file")
fi
done
echo "Changed files: ${notebooks[@]}"
if (( ${#notebooks[@]} == 0 )); then
jupyter nbconvert --to html ${notebooks[@]}
fi
- name: Push and commit new HTML files
#Commits changes to the branch being merged into main
run: |
git config user.name github-actions
git config user.email [email protected]
git add -A
git commit -m "Automated commit for HTML files" || exit 0
git push