Skip to content

PR from a fork

PR from a fork #12

Workflow file for this run

name: Binder Badge
on:
pull_request_target:
types: [opened, synchronize]
pull_request:
types: [opened, synchronize]
jobs:
binder:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: comment on PR with Binder link
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log("GitHub Context:", JSON.stringify(github, null, 2)); # For debugging
var PR_HEAD_REF = github.event.pull_request.head.ref;
var PR_HEAD_USERREPO = github.event.pull_request.head.repo.full_name;
var issue_number = github.event.pull_request.number;
var owner = github.event.pull_request.base.repo.owner.login;
var repo = github.event.pull_request.base.repo.name;
console.log(`Posting comment to ${owner}/${repo} issue #${issue_number}`); # For debugging
github.rest.issues.createComment({
issue_number: issue_number,
owner: owner,
repo: repo,
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://binder.ploomber.io/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}) :point_left: Launch a binder notebook on branch _${PR_HEAD_USERREPO}/${PR_HEAD_REF}_`
});