Skip to content

Instantly share code, notes, and snippets.

@hamelsmu
Created May 20, 2020 21:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamelsmu/f8f98e0fa18852c576973051d3cf72b1 to your computer and use it in GitHub Desktop.
Save hamelsmu/f8f98e0fa18852c576973051d3cf72b1 to your computer and use it in GitHub Desktop.
Label your pull requests with mybinder.org links. This allows collaborators to view your files in a Jupyter Notebook environment with correct dependencies without cloning or building your repo.
name: Binder
on:
pull_request:
types: [opened, reopened]
jobs:
Create-Binder-Badge:
runs-on: ubuntu-latest
steps:
- name: checkout pull request branch
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: comment on PR with Binder link
uses: actions/github-script@v1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var BRANCH_NAME = process.env.BRANCH_NAME;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${context.repo.owner}/${context.repo.repo}/${BRANCH_NAME}) :point_left: Launch a binder notebook on this branch`
})
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
@hamelsmu
Copy link
Author

Place this file in .github/workflows in your GitHub repository. Next time a PR is opened, Actions will drop a link to mybinder.org with a link to the correct branch and repo. Your collaborators can now click on this link and be dropped into a Jupyter notebook environment with the right dependencies without having to build your project.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment