Skip to content

Commit f620863

Browse files
matthewfeickerttwiecki
authored andcommitted
Add Binder build trigger to CI for merged PRs (#3668)
Use the Binder build API to trigger builds on both the GKI and OVH Binder Federation clusters when a PR is merged. This results in the Binder images always being current and should mean that a user never has to wait for an image to be built when they click on the Binder badge
1 parent dfd75c1 commit f620863

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,19 @@ script:
3838

3939
after_success:
4040
- codecov
41+
42+
stages:
43+
- test
44+
- name: binder
45+
if: (branch = master) AND (NOT (type IN (pull_request)))
46+
47+
jobs:
48+
include:
49+
- stage: binder
50+
before_install: skip
51+
install: skip
52+
script:
53+
# Use Binder build API to trigger repo2docker to build image on GKE and OVH Binder Federation clusters
54+
- bash binder/trigger_binder.sh https://gke.mybinder.org/build/gh/pymc-devs/pymc3/"${TRAVIS_BRANCH}"
55+
- bash binder/trigger_binder.sh https://ovh.mybinder.org/build/gh/pymc-devs/pymc3/"${TRAVIS_BRANCH}"
56+
after_success: skip

binder/trigger_binder.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
function trigger_binder() {
4+
local URL="${1}"
5+
6+
curl -L --connect-timeout 10 --max-time 30 "${URL}"
7+
curl_return=$?
8+
9+
# Return code 28 is when the --max-time is reached
10+
if [ "${curl_return}" -eq 0 ] || [ "${curl_return}" -eq 28 ]; then
11+
if [[ "${curl_return}" -eq 28 ]]; then
12+
printf "\nBinder build started.\nCheck back soon.\n"
13+
fi
14+
else
15+
return "${curl_return}"
16+
fi
17+
18+
return 0
19+
}
20+
21+
function main() {
22+
# 1: the Binder build API URL to curl
23+
trigger_binder $1
24+
}
25+
26+
main "$@" || exit 1

0 commit comments

Comments
 (0)