@@ -10,146 +10,39 @@ jobs:
10
10
build-and-deploy :
11
11
runs-on : ubuntu-latest
12
12
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
16
16
17
17
steps :
18
18
- name : Checkout current repository
19
19
uses : actions/checkout@v4
20
20
with :
21
21
path : " current-repo"
22
22
23
- # Cache Docker images
24
- - name : Cache Docker images
25
-
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
-
35
23
- name : Setup Node.js
36
24
uses : actions/setup-node@v4
37
25
with :
38
26
node-version : " 18"
39
27
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
-
55
28
- name : Clone editor-online-preview repository
56
29
run : |
57
30
git clone https://github.com/lvgl-private/editor-test-preview.git /tmp/editor-preview
58
31
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
-
86
32
- name : Prepare preview files
87
33
run : |
34
+ # Create project directory in the preview
88
35
mkdir -p /tmp/editor-preview/project
36
+ # Copy current repo contents to project directory
89
37
cp -r current-repo/* /tmp/editor-preview/project/
90
38
91
39
- name : Generate manifest file
92
40
run : |
93
41
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/"
117
43
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
153
46
154
47
- name : Upload artifact
155
48
uses : actions/upload-pages-artifact@v3
158
51
159
52
- name : Deploy to GitHub Pages
160
53
uses : actions/deploy-pages@v4
54
+ with :
55
+ path : /tmp/editor-preview
0 commit comments