-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (66 loc) · 2.25 KB
/
Copy pathbinder.yml
File metadata and controls
77 lines (66 loc) · 2.25 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Build and Cache Binder Image
on:
push:
branches:
- master
- main
paths:
- 'binder/**'
- 'pyproject.toml'
- 'environment.yml'
- 'requirements.txt'
pull_request:
types: [opened, reopened, synchronize]
paths:
- 'binder/**'
- 'pyproject.toml'
- 'environment.yml'
- 'requirements.txt'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build and trigger binder cache
uses: jupyterhub/repo2docker-action@master
with:
NO_PUSH: "true"
MYBINDERORG_TAG: ${{ github.head_ref || github.ref_name }}
- name: Comment on PR with Binder link
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const BRANCH_NAME = '${{ github.head_ref || github.ref_name }}';
const REPO = '${{ github.repository }}';
const OWNER = REPO.split('/')[0];
const REPO_NAME = REPO.split('/')[1];
const BODY = `🚀 **Binder is ready!**
[](https://mybinder.org/v2/gh/${OWNER}/${REPO_NAME}/${BRANCH_NAME}?urlpath=lab%2Ftree%2Fnotebooks%2Fdemo.ipynb)
Click the badge above to launch the notebook.`;
const { data: comments } = await github.rest.issues.listComments({
owner: OWNER,
repo: REPO_NAME,
issue_number: context.issue.number
});
const binderComment = comments.find(c => c.body.includes('Binder is ready'));
if (binderComment) {
await github.rest.issues.updateComment({
owner: OWNER,
repo: REPO_NAME,
comment_id: binderComment.id,
body: BODY
});
} else {
await github.rest.issues.createComment({
owner: OWNER,
repo: REPO_NAME,
issue_number: context.issue.number,
body: BODY
});
}