Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test the github actions to add a binder badge #230

Closed
wants to merge 53 commits into from
Closed
Changes from 49 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
91feb72
remove push trigger
JessicaS11 Oct 7, 2021
ef4c1ee
add action button
JessicaS11 Oct 7, 2021
2fb44eb
add push trigger back to test
JessicaS11 Oct 7, 2021
aa4e397
remove checkout action for security
JessicaS11 Oct 7, 2021
5bb6ffe
remove paths
JessicaS11 Oct 7, 2021
d040b8c
add permission context
JessicaS11 Oct 7, 2021
7ea835a
updates from GitHub Community post
JessicaS11 Oct 8, 2021
2e8e0bf
create variables from the build in values
JessicaS11 Oct 8, 2021
7c13f2a
try updated mwe
JessicaS11 Oct 8, 2021
cf8de59
try using built in vars
JessicaS11 Oct 8, 2021
99d3e95
re-add checkout
JessicaS11 Oct 8, 2021
4a75d98
try github ref
JessicaS11 Oct 8, 2021
8ee778f
remove branch checkout
JessicaS11 Oct 8, 2021
23a3be2
try calling value a different way
JessicaS11 Oct 8, 2021
ff32472
try base ref
JessicaS11 Oct 8, 2021
7bc9225
try different syntax
JessicaS11 Oct 8, 2021
38436aa
test a bunch of syntax
JessicaS11 Oct 8, 2021
f43c8e9
new list of vars
JessicaS11 Oct 8, 2021
0fd4c44
use github ref
JessicaS11 Oct 8, 2021
f0f6b4f
combine mwe and binder
JessicaS11 Oct 8, 2021
c39a961
separate uses and runs
JessicaS11 Oct 8, 2021
69866f1
reintroduce env vars
JessicaS11 Oct 8, 2021
62ed411
fix indent
JessicaS11 Oct 8, 2021
375e3ec
echo more vars
JessicaS11 Oct 8, 2021
f25ee68
try more vars
JessicaS11 Oct 8, 2021
0df2029
try to extract branch name
JessicaS11 Oct 11, 2021
156767c
try to export as env var
JessicaS11 Oct 11, 2021
484efd0
try setting as env var
JessicaS11 Oct 11, 2021
f01f6ae
try setting as env var
JessicaS11 Oct 11, 2021
8e9f5ee
pass whole ref into env
JessicaS11 Oct 11, 2021
8f91e38
echo line in var declaration
JessicaS11 Oct 11, 2021
8e8d03c
try exporting var earlier in workflow
JessicaS11 Oct 11, 2021
a211a35
fix ref
JessicaS11 Oct 11, 2021
d329804
fix ref
JessicaS11 Oct 11, 2021
bb9a43c
rem env var
JessicaS11 Oct 11, 2021
658be5c
echo branch name var
JessicaS11 Oct 11, 2021
06ebc08
echo branch name var
JessicaS11 Oct 11, 2021
b6b62ea
try to access via env
JessicaS11 Oct 11, 2021
d40752b
try to get it to eval
JessicaS11 Oct 11, 2021
d8b747e
try another way
JessicaS11 Oct 11, 2021
2f318dd
try removing rest of path outside env var getting
JessicaS11 Oct 11, 2021
ea32181
context invalid
JessicaS11 Oct 11, 2021
98bfe73
print out context for ref
JessicaS11 Oct 11, 2021
6986600
try using js to get branch name
JessicaS11 Oct 11, 2021
e45bb2a
fix var calling
JessicaS11 Oct 11, 2021
569bf53
comment out unneeded steps
JessicaS11 Oct 11, 2021
3450d6e
fix binder link
JessicaS11 Oct 12, 2021
dbbfac8
fix binder link extra /
JessicaS11 Oct 12, 2021
543d951
try alternate way to get issue number from second binder example
JessicaS11 Oct 12, 2021
5edae54
try binder-badge action directly
JessicaS11 Oct 12, 2021
f3262d8
try binder-badge action directly
JessicaS11 Oct 12, 2021
2d92357
try using orig name to test
JessicaS11 Oct 12, 2021
5ddd01b
return to original action implementation
JessicaS11 Oct 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions .github/workflows/binder-badge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,41 @@ name: AddBinderBadge
on:
push:
pull_request_target:
# since we're using nbgitpuller, only create the badge when PR opened
types: [opened]
JessicaS11 marked this conversation as resolved.
Show resolved Hide resolved
paths:
- 'examples/*'

jobs:
add-badge:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v2
# - name: Checkout PR
# uses: actions/checkout@v2
# - name: print vars
# run: |
# echo ${{ github.head_ref}}
# echo ${{ github.ref}}
# echo ${{ github.base_ref}}
# echo ${GITHUB_REF#refs/heads/}
# - name: get branch name
# run: |
# echo ${GITHUB_REF#refs/heads/}
# export GIT_BRANCH=$(echo ${GITHUB_REF#refs/heads/})
# echo $GIT_BRANCH

- name: Comment on PR with Binder link
uses: actions/github-script@v5
JessicaS11 marked this conversation as resolved.
Show resolved Hide resolved
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
CONTENT_REPO: ${{github.event.pull_request.head.repo.full_name}}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var BRANCH_NAME = process.env.BRANCH_NAME;
console.log(context)
var BRANCH_NAME = process.env.GITHUB_REF.replace("refs/heads", "");
var CONTENT_REPO = process.env.CONTENT_REPO;
github.rest.issues.createComment({
issue_number: context.issue.number,
issue_number: context.payload.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/icesat2py/icepyx/main?urlpath=git-pull%3Frepo%3Dhttps%253A%252F%252Fgithub.com%252F${CONTENT_REPO}%26urlpath%3Dlab%252Ftree%252Ficepyx%252Fexamples%252F%26branch%3D${BRANCH_NAME}) :point_left: Launch a binder notebook on this branch`
})
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${CONTENT_REPO}/${BRANCH_NAME}?labpath=examples) :point_left: Launch a binder notebook on this branch`
})
# NOTE: Setting the vars as env vars is required to make them available within the Comment on PR step
env:
GITHUB_REF: ${{ github.ref }}
CONTENT_REPO: ${{ github.repository }}