Adding github token #2
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: Prettify Python and Clean Jupyter Notebooks | |
on: | |
push: | |
branches: | |
- main # Replace with your default branch if different | |
jobs: | |
prettify-and-clean: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
pip install autopep8 | |
pip install nbconvert | |
- name: Prettify Python Code | |
run: | | |
autopep8 --in-place --recursive --aggressive --aggressive . | |
- name: Remove Output from Jupyter Notebooks | |
run: | | |
find . -name "*.ipynb" -exec jupyter nbconvert --ClearOutputPreprocessor.enabled=True --inplace {} \; | |
- name: Check for modified files | |
id: git-check | |
run: | | |
git diff --exit-code || echo "git-diff-exit-code=$?" >> $GITHUB_ENV | |
- name: Commit and Push Changes | |
if: env.git-diff-exit-code == '1' | |
run: | | |
git config --global user.name 'GitHub Action' | |
git config --global user.email '[email protected]' | |
git add -A | |
git commit -m "Automated code prettification and notebook cleanup" | |
git push |