@@ -10,146 +10,39 @@ jobs:
1010 build-and-deploy :
1111 runs-on : ubuntu-latest
1212 permissions :
13- contents : write
14- pages : write
15- id-token : write
13+ contents : write # Required for pushing to gh-pages
14+ pages : write # Required for deploying to Pages
15+ id-token : write # Required for deploying to Pages
1616
1717 steps :
1818 - name : Checkout current repository
1919 uses : actions/checkout@v4
2020 with :
2121 path : " current-repo"
2222
23- # Cache Docker images
24- - name : Cache Docker images
25- uses : ScribeMD/docker-cache@0.3.7
26- with :
27- key : docker-${{ runner.os }}-${{ hashFiles('current-repo/**/*.c', 'current-repo/**/*.h') }}
28-
29- - name : Set up Docker
30- uses : docker/setup-buildx-action@v3
31-
32- - name : Pull Docker image
33- run : docker pull coevin/emscripten-sdl2:main
34-
3523 - name : Setup Node.js
3624 uses : actions/setup-node@v4
3725 with :
3826 node-version : " 18"
3927
40- # Get LVGL PR latest commit hash
41- - name : Get LVGL PR latest commit
42- id : lvgl-commit
43- run : |
44- COMMIT_HASH=$(curl -s https://api.github.com/repos/lvgl/lvgl/pulls/7417 | jq -r .head.sha)
45- echo "commit_hash=${COMMIT_HASH}" >> $GITHUB_OUTPUT
46-
47- # Cache LVGL PR with commit hash in key
48- - name : Cache LVGL PR
49- id : cache-lvgl
50- uses : actions/cache@v3
51- with :
52- path : /tmp/runtime/lvgl
53- key : lvgl-pr7417-${{ steps.lvgl-commit.outputs.commit_hash }}
54-
5528 - name : Clone editor-online-preview repository
5629 run : |
5730 git clone https://github.com/lvgl-private/editor-test-preview.git /tmp/editor-preview
5831
59- - name : Clone LVGL PR
60- if : steps.cache-lvgl.outputs.cache-hit != 'true'
61- run : |
62- # Create runtime directory
63- mkdir -p /tmp/runtime
64- # Copy resources to runtime directory
65- cp -r /tmp/editor-preview/resources/* /tmp/runtime/
66- # Clone LVGL PR
67- git clone https://github.com/lvgl/lvgl.git /tmp/runtime/lvgl
68- cd /tmp/runtime/lvgl
69- git fetch origin pull/7417/head:pr-7417
70- git checkout pr-7417
71-
72- - name : Copy resources if using cached LVGL
73- if : steps.cache-lvgl.outputs.cache-hit == 'true'
74- run : |
75- mkdir -p /tmp/runtime
76- cp -r /tmp/editor-preview/resources/* /tmp/runtime/
77-
78- # Cache build directory with LVGL commit hash
79- - name : Cache build directory
80- id : cache-build
81- uses : actions/cache@v3
82- with :
83- path : /tmp/build
84- key : build-${{ runner.os }}-${{ steps.lvgl-commit.outputs.commit_hash }}-${{ hashFiles('current-repo/**/*.c', 'current-repo/**/*.h') }}
85-
8632 - name : Prepare preview files
8733 run : |
34+ # Create project directory in the preview
8835 mkdir -p /tmp/editor-preview/project
36+ # Copy current repo contents to project directory
8937 cp -r current-repo/* /tmp/editor-preview/project/
9038
9139 - name : Generate manifest file
9240 run : |
9341 cd /tmp/editor-preview
94- node generateProjectManifest.js ./project/ /project/
95-
96- - name : Prepare widget list
97- id : widget-list
98- run : |
99- WIDGET_LIST="[]"
100- if [ -d "current-repo/widgets" ]; then
101- # Find directories in widgets that contain .c files
102- WIDGETS=$(find current-repo/widgets -type f -name "*.c" -exec dirname {} \; | sort -u | xargs -n1 basename)
103- if [ ! -z "$WIDGETS" ]; then
104- # Convert to array of '_widgetname_register'
105- WIDGET_LIST="[$(echo "$WIDGETS" | tr ' ' '\n' | sed "s/.*/'_&_register'/" | tr '\n' ',' | sed 's/,$//' )]"
106- fi
107- fi
108- echo "widget_functions=$WIDGET_LIST" >> $GITHUB_OUTPUT
109-
110- # Cache LVGL library
111- - name : Cache LVGL library
112- id : cache-lvgl-lib
113- uses : actions/cache@v3
114- with :
115- path : /tmp/runtime/lib/liblvgl.a
116- key : lvgl-lib-${{ steps.lvgl-commit.outputs.commit_hash }}
42+ node generateProjectManifest.js ./project/ "project/"
11743
118- - name : Build LVGL library
119- if : steps.cache-lvgl-lib.outputs.cache-hit != 'true'
120- run : |
121- docker run --rm \
122- -v /tmp/runtime:/work \
123- -w /work/lib \
124- coevin/emscripten-sdl2:main \
125- sh -c 'mkdir -p /tmp/build && \
126- cd /tmp/build && \
127- emcmake cmake /work/lib && \
128- emmake make -j8 && \
129- mkdir -p /work/lib && \
130- cp /tmp/build/liblvgl.a /work/lib/'
131-
132- - name : Build runtime
133- run : |
134- # Create build directory
135- mkdir -p /tmp/build
136-
137- # Run CMake in Docker
138- docker run --rm \
139- -v /tmp/runtime:/work \
140- -v /tmp/editor-preview/project/resources:/output \
141- -v /tmp/build:/build \
142- -v ${{ github.workspace }}/current-repo:/user_src \
143- -w /build \
144- coevin/emscripten-sdl2:main \
145- sh -c 'emcmake cmake -DPROJECT_NAME=lved-runtime \
146- -DOUTPUT_DIR=/output \
147- -DLVGL_SRC_DIR=/work/lvgl \
148- -DLVGL_CONF_DIR=/work/conf \
149- -DUSER_SRC_DIR=/user_src \
150- -DADDITIONAL_EXPORTED_FUNCTIONS="${{ steps.widget-list.outputs.widget_functions }}" \
151- /work && \
152- emmake make -j8'
44+ - name : Setup Pages
45+ uses : actions/configure-pages@v4
15346
15447 - name : Upload artifact
15548 uses : actions/upload-pages-artifact@v3
15851
15952 - name : Deploy to GitHub Pages
16053 uses : actions/deploy-pages@v4
54+ with :
55+ path : /tmp/editor-preview
0 commit comments