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
app:
cache:
paths:
- node_modules/
stage: deploy
script:
- npm install -g elm
- elm make --yes src/Main.elm --output=public/script.js
artifacts:
paths:
- public
only:
- master
I suppose the entry point is src/Main.elm
- Create
public/index.html
:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>My title</title>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
</body>
<script type="text/javascript">
Elm.Main.fullscreen();
</script>
</html>
FYI this doesn’t work as shown with newer nodes and/or Elm 0.19 for (at least) three reasons (which all have workarounds):
-
npm install -g
is broken.
Fix: Add -- unsafe-perm=true
.
-
--yes
is no longer a thing.
Fix: Remove --yes
.
-
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