How to run an elm project from gitlab?

I am currently learning the elm language, and I noticed that in some github pages, there are Try it! links to test the app. Here an example.

How to do the same?

I suppose that at each push, a container is regenerated with the appropriate stuff, and whenever someone click on the link, he get the app from the container. Does someone have advice / documentation about this?

Sorry if my question is trivial, I am a total beginner about CI (is this is related).

1 Like

I managed to find how to do it:

  • create .gitlab-ci.yml at the root of the repository:
image: node:4.2.2

    - node_modules/
  stage: deploy
  - npm install -g elm
  - elm make --yes src/Main.elm --output=public/script.js
    - public
  - master

I suppose the entry point is src/Main.elm

  • Create public/index.html:

  <meta charset="UTF-8">
  <title>My title</title>
  <script type="text/javascript" src="script.js"></script>


<script type="text/javascript">

FYI this doesn’t work as shown with newer nodes and/or Elm 0.19 for (at least) three reasons (which all have workarounds):

  1. npm install -g is broken.
    Fix: Add -- unsafe-perm=true.

  2. --yes is no longer a thing.
    Fix: Remove --yes.

  3. Having elm-stuff checked in will cause a CORRUPT BINARY error.
    Fix: Add elm-stuff to your .gitignore.

1 Like

I also have a PR open to add an Elm example to the GitLab pages repo.

1 Like