Skip to content

Commit

Permalink
Build examples using github actions (#13)
Browse files Browse the repository at this point in the history
* build examples with parcel

* adds github action to deploy

* adds temp master branch
  • Loading branch information
andrewMacmurray authored Feb 26, 2021
1 parent b309896 commit 4a9ba99
Show file tree
Hide file tree
Showing 11 changed files with 6,822 additions and 31 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Deploy Examples

on:
push:
branches:
- main
- master

jobs:
deploy-examples:
runs-on: ubuntu-latest
env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- uses: actions/cache@v2
with:
path: ~/.elm
key: ${{ runner.os }}-elm-${{ hashFiles('**/elm.json') }}
restore-keys: ${{ runner.os }}-elm-

- run: npm ci
- run: npm run examples:build
- run: npm run surge:push
16 changes: 11 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# elm-package generated files
# elm
elm-stuff/
# elm-repl generated files
repl-temp-*

documentation.json

examples/elm.js
tests/elm.js

# JS
node_modules
.cache

# build
dist

# editor
.idea
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Elm utilities to trigger updates after a delay

**example**: https://wakeful-treatment.surge.sh/
**example**: https://elm-delay-examples.surge.sh/
**tests**: https://near-pie.surge.sh/

### Why?
Expand Down
13 changes: 7 additions & 6 deletions examples/elm.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
"type": "application",
"source-directories": [
".",
"src",
"../src"
],
"elm-version": "0.19.0",
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/browser": "1.0.2",
"elm/core": "1.0.5",
"elm/html": "1.0.0"
},
"indirect": {
"elm/json": "1.0.0",
"elm/json": "1.1.3",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm/virtual-dom": "1.0.0"
"elm/virtual-dom": "1.0.2"
}
},
"test-dependencies": {
Expand Down
16 changes: 0 additions & 16 deletions examples/index.html

This file was deleted.

31 changes: 28 additions & 3 deletions examples/Sequence.elm → examples/src/Main.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Sequence exposing (main)
module Main exposing (main)

import Browser
import Delay
Expand All @@ -7,6 +7,10 @@ import Html.Attributes exposing (class, style)
import Html.Events exposing (onClick)



-- Model


type alias Model =
{ color : String
, colorCycling : Bool
Expand All @@ -21,6 +25,10 @@ type Msg
| ColorCycling Bool



-- Init


init : ( Model, Cmd Msg )
init =
( { color = "#1E70B5"
Expand All @@ -30,16 +38,25 @@ init =
)



-- Sequence


cycleColors : Model -> Cmd Msg
cycleColors model =
Delay.sequenceIf (not model.colorCycling) <|
Delay.withUnit Delay.Millisecond
Delay.sequenceIf (not model.colorCycling)
(Delay.withUnit Delay.Millisecond
[ ( 0, ColorCycling True )
, ( 0, Red )
, ( 2000, Green )
, ( 2000, Blue )
, ( 2000, ColorCycling False )
]
)



-- Update


update : Msg -> Model -> ( Model, Cmd Msg )
Expand All @@ -61,6 +78,10 @@ update msg model =
( { model | colorCycling = bool }, Cmd.none )



-- View


view : Model -> Html Msg
view { color } =
div
Expand All @@ -71,6 +92,10 @@ view { color } =
[ text "click to cycle through the colors" ]



-- App


main : Program () Model Msg
main =
Browser.element
Expand Down
11 changes: 11 additions & 0 deletions examples/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Delay Example</title>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<div id="app"></div>
<script src="./index.js"></script>
</body>
</html>
6 changes: 6 additions & 0 deletions examples/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Elm } from "./Main";

Elm.Main.init({
node: document.getElementById("app"),
flags: null,
});
File renamed without changes.
Loading

0 comments on commit 4a9ba99

Please sign in to comment.