-
Notifications
You must be signed in to change notification settings - Fork 291
42 lines (41 loc) · 1.18 KB
/
cleanup.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
name: Clean Notebooks
on:
pull_request_review:
types: [submitted]
workflow_dispatch:
jobs:
fix:
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install Dependencies
run: |
python -m pip install nb_helpers
- name: Clean up .ipynb files
run: |
nb_helpers.fix_nbs ./colabs/
- name: Commit and push if changed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
git add -A
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Auto-clean notebooks"
git push origin HEAD:${{ github.event.pull_request.head.ref }}
fi