Created
May 9, 2024 05:04
-
-
Save ArthurFDLR/6aa3f00821014b552cca6a541ff10d4c to your computer and use it in GitHub Desktop.
Github Action to update the README.md with the content of a README.ipynb
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: Convert README.ipynb to README.md | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '**/README.ipynb' | |
jobs: | |
convert-notebook: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install nbconvert | |
run: | | |
python -m pip install --upgrade pip | |
pip install nbconvert | |
- name: Convert README.ipynb to README.md | |
run: jupyter-nbconvert --to markdown README.ipynb | |
- name: Commit and push if changes | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add README.md | |
git commit -m "Update README.md" || exit 0 # Do nothing if no changes | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment