-
Notifications
You must be signed in to change notification settings - Fork 1
385 lines (363 loc) · 14 KB
/
setup-environment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
name: Setup Environment
on:
push:
branches:
- main
jobs:
setup-environment:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Create directories for course
run: |
mkdir -p course-materials/lectures
mkdir -p course-materials/exercises
mkdir -p course-materials/resources
mkdir -p practical-lab-work
mkdir -p web-portal
mkdir -p web-portal/css
mkdir -p web-portal/js
mkdir -p web-portal/assets
- name: Verify directory structure
run: |
ls -la course-materials
ls -la practical-lab-work
ls -la web-portal
- name: Create initial course files
run: |
echo "# Lectures" > course-materials/lectures/README.md
echo "# Exercises" > course-materials/exercises/README.md
echo "# Resources" > course-materials/resources/README.md
echo "# Practical Lab Work" > practical-lab-work/README.md
cat <<EOF > web-portal/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mobile App Development for Juniors</title>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/styles.css">
<script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-firestore.js"></script>
</head>
<body>
<header>
<h1>Mobile App Development for Juniors</h1>
<h2>Course Code: MADJ101</h2>
<h3>Building Foundational Skills for Future App Developers</h3>
</header>
<nav>
<ul>
<li><a href="lectures.html">Lectures</a></li>
<li><a href="exercises.html">Exercises</a></li>
<li><a href="resources.html">Resources</a></li>
<li><a href="practical-lab.html">Practical Lab Work</a></li>
</ul>
</nav>
<main>
<section id="content">
<h2>Welcome to the Course Portal</h2>
<p>Navigate through the sections to access course materials and lab exercises.</p>
<div id="auth-container">
<div id="login-form">
<h3>Login</h3>
<input type="email" id="login-email" placeholder="Email">
<input type="password" id="login-password" placeholder="Password">
<button onclick="login()">Login</button>
</div>
<div id="register-form">
<h3>Register</h3>
<input type="email" id="register-email" placeholder="Email">
<input type="password" id="register-password" placeholder="Password">
<button onclick="register()">Register</button>
</div>
</div>
</section>
</main>
<footer>
<p>© 2024 Skunkworks (Pty) Ltd. All rights reserved.</p>
</footer>
<script src="js/scripts.js"></script>
</body>
</html>
EOF
cat <<EOF > web-portal/css/styles.css
/* CSS styles for the course portal */
body {
font-family: "IBM Plex Sans", sans-serif;
background-color: #f4f4f9;
color: #333;
margin: 0;
padding: 0;
}
header {
background-color: #1a73e8;
color: white;
text-align: center;
padding: 20px 0;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
header h1 {
font-size: 2.5em;
margin: 0.2em 0;
font-weight: 700;
}
header h2 {
font-size: 1.2em;
margin: 0.2em 0;
font-weight: 400;
}
header h3 {
font-size: 1em;
margin: 0.2em 0;
font-weight: 400;
}
nav ul {
list-style: none;
padding: 0;
display: flex;
justify-content: center;
background-color: #1a73e8;
margin: 0;
}
nav ul li {
margin: 0 15px;
}
nav ul li a {
color: white;
text-decoration: none;
font-weight: 700;
}
nav ul li a:hover {
text-decoration: underline;
}
main {
padding: 20px;
}
footer {
text-align: center;
padding: 10px 0;
background-color: #1a73e8;
color: white;
position: fixed;
width: 100%;
bottom: 0;
}
EOF
cat <<EOF > web-portal/js/scripts.js
// Firebase configuration
const firebaseConfig = {
apiKey: "${{ secrets.AISTUDIO_API_KEY }}",
authDomain: "course-madj101.firebaseapp.com",
projectId: "course-madj101",
storageBucket: "course-madj101.appspot.com",
messagingSenderId: "491294238145",
appId: "1:491294238145:web:66bcaff49ae8f7faed3b40",
measurementId: "G-GDQCV0XQVJ"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
const db = firebase.firestore();
// Login function
function login() {
const email = document.getElementById("login-email").value;
const password = document.getElementById("login-password").value;
auth.signInWithEmailAndPassword(email, password)
.then((userCredential) => {
const user = userCredential.user;
alert("Login successful!");
// Redirect to course materials page or update UI accordingly
})
.catch((error) => {
alert("Login failed: " + error.message);
});
}
// Register function
function register() {
const email = document.getElementById("register-email").value;
const password = document.getElementById("register-password").value;
auth.createUserWithEmailAndPassword(email, password)
.then((userCredential) => {
const user = userCredential.user;
alert("Registration successful!");
// Save user data to Firestore
db.collection("users").doc(user.uid).set({
email: email,
progress: {
lectures: [],
exercises: [],
labWork: []
}
});
// Redirect to course materials page or update UI accordingly
})
.catch((error) => {
alert("Registration failed: " + error.message);
});
}
// Function to update progress
function updateProgress(section, item) {
const user = auth.currentUser;
if (user) {
const userDocRef = db.collection("users").doc(user.uid);
userDocRef.update({
["progress." + section]: firebase.firestore.FieldValue.arrayUnion(item)
}).then(() => {
alert("Progress updated!");
}).catch((error) => {
alert("Error updating progress: " + error.message);
});
} else {
alert("No user logged in!");
}
}
// Function to submit quiz
function submitQuiz() {
const user = auth.currentUser;
if (user) {
const form = document.getElementById("quiz-form");
const answers = {
question1: form.elements["question1"].value,
question2: form.elements["question2"].value
};
db.collection("users").doc(user.uid).collection("assessments").add({
quiz: answers,
timestamp: firebase.firestore.FieldValue.serverTimestamp()
}).then(() => {
alert("Quiz submitted!");
}).catch((error) => {
alert("Error submitting quiz: " + error.message);
});
} else {
alert("No user logged in!");
}
}
EOF
- name: Create quiz page
run: |
cat <<EOF > web-portal/quiz.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quiz</title>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<header>
<h1>Course Quiz</h1>
</header>
<main>
<section id="quiz-content">
<form id="quiz-form">
<h2>Question 1</h2>
<p>What is the purpose of an MVP?</p>
<input type="radio" name="question1" value="A"> A. To develop a full-featured product<br>
<input type="radio" name="question1" value="B"> B. To gather early feedback<br>
<input type="radio" name="question1" value="C"> C. To avoid user testing<br>
<h2>Question 2</h2>
<p>Which tool is used for version control?</p>
<input type="radio" name="question2" value="A"> A. Git<br>
<input type="radio" name="question2" value="B"> B. Docker<br>
<input type="radio" name="question2" value="C"> Jenkins<br>
<button type="button" onclick="submitQuiz()">Submit</button>
</form>
</section>
</main>
<footer>
<p>© 2024 Skunkworks (Pty) Ltd. All rights reserved.</p>
</footer>
<script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.6.1/firebase-firestore.js"></script>
<script src="js/scripts.js"></script>
</body>
</html>
EOF
- name: Create package.json
run: |
if [ ! -f package.json ]; then
cat <<EOF > package.json
{
"name": "madj101",
"version": "1.0.0",
"description": "Mobile App Development for Juniors",
"main": "index.js",
"scripts": {
"test": "echo \\"Error: no test specified\\" && exit 1",
"build": "webpack --config webpack.config.js"
},
"author": "Raydo Matthee",
"license": "ISC",
"dependencies": {
"webpack": "^5.0.0",
"webpack-cli": "^4.0.0"
}
}
EOF
fi
- name: Create webpack.config.js
run: |
cat <<EOF > webpack.config.js
const path = require("path");
module.exports = {
entry: "./web-portal/js/scripts.js",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "web-portal/js")
},
mode: "production"
};
EOF
- name: Install dependencies
run: npm install
- name: Build project
run: npm run build
- name: Deploy to Fireba se
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_COURSE_MADJ101 }}
channelId: live
projectId: course-madj101
- name: Verify deployment
run: |
curl https://course-madj101.web.app
curl https://course-madj101.web.app/lectures.html
curl https://course-madj101.web.app/exercises.html
curl https://course-madj101.web.app/resources.html
curl https://course-madj101.web.app/practical-lab.html
curl https://course-madj101.web.app/quiz.html
curl https://course-madj101.web.app/css/styles.css
curl https://course-madj101.web.app/js/bundle.js
curl https://course-madj101.web.app/js/scripts.js
curl https://course-madj101.web.app/index.html
curl https://course-madj101.web.app/404.html
curl https://course-madj101.web.app/favicon.ico
curl https://course-madj101.web.app/robots.txt
curl https://course-madj101.web.app/manifest.json
curl https://course-madj101.web.app/sw.js
curl https://course-madj101.web.app/firebase-messaging-sw.js
curl https://course-madj101.web.app/__/firebase/init.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-app.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-auth.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-firestore.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-messaging.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-performance.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-storage.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-analytics.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-remote-config.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-functions.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-database.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-ml.js
curl https://course-madj101.web.app/__/firebase/9.6.1/firebase-ml-natural-language.js