From 489a9d812b2e0444cba08f9d7beb7863d21a48d0 Mon Sep 17 00:00:00 2001 From: Ian Hunt-Isaak Date: Thu, 4 Mar 2021 16:08:58 -0500 Subject: [PATCH] add action to comment on PRs with a binder link --- .github/workflows/binder-on-pr.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/binder-on-pr.yml diff --git a/.github/workflows/binder-on-pr.yml b/.github/workflows/binder-on-pr.yml new file mode 100644 index 0000000000..07d19164ab --- /dev/null +++ b/.github/workflows/binder-on-pr.yml @@ -0,0 +1,26 @@ +# Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html +name: Binder Badge +on: + pull_request_target: + types: [opened] + +jobs: + binder: + runs-on: ubuntu-latest + steps: + - name: comment on PR with Binder link + uses: actions/github-script@v1 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO; + var PR_HEAD_REF = process.env.PR_HEAD_REF; + 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/${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}_` + }) + env: + PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} + PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}