forked from NeuromatchAcademy/course-content
-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (43 loc) · 1.47 KB
/
tutorial-readme-pr.yaml
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
46
47
48
49
50
51
52
name: tutorial-readme-pr
on:
pull_request:
branches: main
paths:
- tutorials/materials.yaml
jobs:
generate-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install CI tools
run: |
BRANCH=`python -c 'import os, re; m = re.search(r"nmaci:([\w-]+)", os.environ["COMMIT_MESSAGE"]); print("main" if m is None else m.group(1))'`
wget https://github.com/NeuromatchAcademy/nmaci/archive/refs/heads/$BRANCH.tar.gz
tar -xzf $BRANCH.tar.gz
mv nmaci-$BRANCH/scripts/ ci/
rm -r nmaci-$BRANCH
echo ci/ >> .gitignore
- name: Update READMEs
run: python ci/generate_tutorial_readmes.py
- name: Commit post-processed files
if: ${{ success() }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add '**/README.md'
git diff-index --quiet HEAD || git commit -m "Update tutorial README"
- name: Push post-processed files
if: ${{ success() }}
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}