Skip to content

Commit 98e6c86

Browse files
authored
Merge pull request #3148 from ianhi/binder-on-prs
Add action to comment on PRs with a binder link
2 parents 1a12162 + 489a9d8 commit 98e6c86

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

.github/workflows/binder-on-pr.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html
2+
name: Binder Badge
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
jobs:
8+
binder:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: comment on PR with Binder link
12+
uses: actions/github-script@v1
13+
with:
14+
github-token: ${{secrets.GITHUB_TOKEN}}
15+
script: |
16+
var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO;
17+
var PR_HEAD_REF = process.env.PR_HEAD_REF;
18+
github.issues.createComment({
19+
issue_number: context.issue.number,
20+
owner: context.repo.owner,
21+
repo: context.repo.repo,
22+
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}?urlpath=lab/tree/docs/source/examples/) :point_left: Launch a binder notebook on branch _${PR_HEAD_USERREPO}/${PR_HEAD_REF}_`
23+
})
24+
env:
25+
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
26+
PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}

0 commit comments

Comments
 (0)