From 932bed4af79a2fc87f6c3ac79f93552e87aab1a0 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Mon, 29 Mar 2021 13:10:38 +0200 Subject: [PATCH] Add action to comment with a Binder link on PRs --- .github/workflows/binder.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/binder.yml diff --git a/.github/workflows/binder.yml b/.github/workflows/binder.yml new file mode 100644 index 000000000..b6394534a --- /dev/null +++ b/.github/workflows/binder.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@v3 + 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=classic/tree) :point_left: Launch JupyterLab Classic on Binder` + }) + env: + PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} + PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}