Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit 254c574

Browse files
authored
Create binder-on-pr.yaml
1 parent 3560915 commit 254c574

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
binder:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: comment on PR with Binder link
15+
uses: actions/github-script@v3
16+
with:
17+
github-token: ${{secrets.GITHUB_TOKEN}}
18+
script: |
19+
var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO;
20+
var PR_HEAD_REF = process.env.PR_HEAD_REF;
21+
github.issues.createComment({
22+
issue_number: context.issue.number,
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}?urlpath=lab) :point_left: Launch a binder notebook on branch _${PR_HEAD_USERREPO}/${PR_HEAD_REF}_`
26+
})
27+
env:
28+
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
29+
PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}

0 commit comments

Comments
 (0)