-
Notifications
You must be signed in to change notification settings - Fork 6
44 lines (39 loc) · 1.21 KB
/
nbviewer.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
43
44
name: Generate nbviewer links
on:
pull_request:
types:
- opened
- edited
paths:
- "**.ipynb"
jobs:
nbviewer-links:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: get files
id: files
uses: jitterbit/get-changed-files@v1
continue-on-error: true
- name: add comments
uses: actions/github-script@v3
env:
FILES: ${{steps.files.outputs.all}}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const body = process.env.FILES
.split(" ")
.filter(f => (f.endsWith(".ipynb") && !f.startsWith("portfolio/")))
.map(f => `* [${f}](https://nbviewer.jupyter.org/github/${context.repo.owner}/${context.repo.repo}/blob/${context.sha}/${f})`)
if (body.length > 0) {
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "nbviewer URLs for impacted notebooks:\n\n" + body.join("\n")
})
}