# How to build mybinder image automatically at each commit

**URL:** <https://discourse.jupyter.org/t/how-to-build-mybinder-image-automatically-at-each-commit/5381>\
**Category:** Binder\
**Created:** [July 27, 2020, 9:17am UTC](https://discourse.jupyter.org/t/how-to-build-mybinder-image-automatically-at-each-commit/5381 "2020-07-27T09:17:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/sylvaticus/32/2394_2.png) [@sylvaticus](https://discourse.jupyter.org/u/sylvaticus)\
**Post date:** [July 27, 2020, 9:17am UTC](https://discourse.jupyter.org/t/how-to-build-mybinder-image-automatically-at-each-commit/5381/1 "2020-07-27T09:17:19Z")

</div>

I have a [Julia-based repository](https://github.com/sylvaticus/BetaML.jl) that uses some notebooks, with the documentation pointing to their mybinder/ instance.

The problem is that the first user that clicks on them after a commit will have to wait a while.  
I am hence trying to automatise the building of the mybinder image.

I set the following on `.github/workflow/binder.yaml`:

```auto
name: Binder
on: [push]

jobs:
  Create-Binder-Badge:
    runs-on: ubuntu-latest
    steps:
    - name: cache binder build on mybinder.org
      uses: machine-learning-apps/repo2docker-action@0.2
      with:
        NO_PUSH: true
        MYBINDERORG_TAG: ${{ github.event.ref }} # This builds the container on mybinder.org with the branch that was pushed on.

```

However at each commit I receive the following [“run failed” error](https://github.com/sylvaticus/BetaML.jl/runs/902873331):

![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/7/7682389a4b6cd5c796df761460c90796b8819e10.png)

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/b/b38c04b2cf5a579bdcae14b104c4363c07ae2b24.png)  
 ![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/e/ef4d450d4cc0ac707bd14a50ac446ce3907b01f4.png)

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [July 27, 2020, 10:28am UTC](https://discourse.jupyter.org/t/how-to-build-mybinder-image-automatically-at-each-commit/5381/2 "2020-07-27T10:28:20Z")

</div>

[https://github.com/sylvaticus/BetaML.jl/runs/902873331#step:3:35](https://github.com/sylvaticus/BetaML.jl/runs/902873331#step:3:35) : `jupyter-repo2docker: error: argument --image-name: 'sylvaticus/BetaML.jl:cde0f752c685' is not a valid docker image name. Image namemust start with an alphanumeric character andcan then use _ . or - in addition to alphanumeric.`

The image name is invalid, as shown by trying `docker tag` locally:

```auto
$ docker tag busybox sylvaticus/BetaML.jl:cde0f752c685

Error parsing reference: "sylvaticus/BetaML.jl:cde0f752c685" is not a valid repository/tag: invalid reference format: repository name must be lowercase
Error parsing reference: "sylvaticus/BetaML.jl:cde0f752c685" is not a valid repository/tag: invalid reference format: repository name must be lowercase

```

You could try overriding the image name using `IMAGE_NAME`:

> <https://github.com/jupyterhub/repo2docker-action/blob/c62a8dd43e7fdfc9d1bb719da9901dec2afc4b81/action.yml#L13-L14>

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/sylvaticus/32/2394_2.png) [@sylvaticus](https://discourse.jupyter.org/u/sylvaticus)\
**Post date:** [July 27, 2020, 11:26am UTC](https://discourse.jupyter.org/t/how-to-build-mybinder-image-automatically-at-each-commit/5381/3 "2020-07-27T11:26:35Z")

</div>

Thank you.  
I can confirm that this indeed works:

```auto
name: Binder
on: push

jobs:
  Create-MyBinderOrg-Cache:
    runs-on: ubuntu-latest
    steps:
    - name: cache binder build on mybinder.org
      uses: jupyterhub/repo2docker-action@master
      with:
        NO_PUSH: true
        MYBINDERORG_TAG: ${{ github.event.ref }} # This builds the container on mybinder.org with the branch that was pushed on.
        IMAGE_NAME: sylvaticus/betaml

```

If I understood it clearly, maybe the script on [https://github.com/jupyterhub/repo2docker-action/blob/c62a8dd43e7fdfc9d1bb719da9901dec2afc4b81/trigger\_binder.sh](https://github.com/jupyterhub/repo2docker-action/blob/c62a8dd43e7fdfc9d1bb719da9901dec2afc4b81/trigger_binder.sh) would benefit of a lowercase() function to account for repositories with upper case names ?

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [July 27, 2020, 12:03pm UTC](https://discourse.jupyter.org/t/how-to-build-mybinder-image-automatically-at-each-commit/5381/4 "2020-07-27T12:03:36Z")

</div>

@hamel What do you think? Are there any other forbidden Docker characters than are allowed in GitHub repository names?

---

<div class="post-metadata">

**Author:** ![hamel](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/hamel/32/1302_2.png) [@hamel](https://discourse.jupyter.org/u/hamel)\
**Post date:** [July 27, 2020, 4:54pm UTC](https://discourse.jupyter.org/t/how-to-build-mybinder-image-automatically-at-each-commit/5381/5 "2020-07-27T16:54:23Z")

</div>

I believe it that is a restriction that repo2docker has and isn’t specific to the GitHub Action. Might be worth asking in that repo?

Edit: sorry I misread! Yes there could be GitHub vs Docker name collision

Is lowercase the only issue in this case? Do you want to make a PR or should I fix it?

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [July 27, 2020, 7:35pm UTC](https://discourse.jupyter.org/t/how-to-build-mybinder-image-automatically-at-each-commit/5381/6 "2020-07-27T19:35:30Z")

</div>

Here’s my attempt! [https://github.com/jupyterhub/repo2docker-action/pull/44](https://github.com/jupyterhub/repo2docker-action/pull/44)

---

<div class="post-metadata">

**Author:** ![hamel](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/hamel/32/1302_2.png) [@hamel](https://discourse.jupyter.org/u/hamel)\
**Post date:** [July 27, 2020, 8:37pm UTC](https://discourse.jupyter.org/t/how-to-build-mybinder-image-automatically-at-each-commit/5381/7 "2020-07-27T20:37:52Z")

</div>

🚀 Merged 🚀 Great Job

> [@manics](#):
>
> Here’s my attempt! [https://github.com/jupyterhub/repo2docker-action/pull/44](https://github.com/jupyterhub/repo2docker-action/pull/44)
