Skip to content

Commit

Permalink
Firebase setup
Browse files Browse the repository at this point in the history
  • Loading branch information
burnt-exe committed Jun 2, 2024
1 parent 1346f3b commit ba760f1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 91 deletions.
103 changes: 16 additions & 87 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -1,109 +1,38 @@
name: Build and Test
name: Build and Deploy

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-test:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Create package.json if not exists
run: |
if [ ! -f package.json ]; then
echo '{
"name": "madj101",
"version": "1.0.0",
"description": "Mobile App Development for Juniors",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Raydo Matthee",
"license": "ISC",
"dependencies": {}
}' > package.json
fi
- name: Install dependencies
run: npm install

- name: Verify HTML, CSS, and JavaScript
run: |
npx html-validate web-portal/index.html
npx stylelint "web-portal/css/**/*.css"
npx eslint web-portal/js/**/*.js
- name: Create quiz page
run: |
echo '<!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"> Git<br>
<input type="radio" name="question2" value="B"> Docker<br>
<input type="radio" name="question2" value="C"> Jenkins<br>
<button type="button" onclick="submitQuiz()">Submit</button>
</form>
</section>
</main>
<footer>
<p>&copy; 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>' > web-portal/quiz.html
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: web-portal
- name: Build project
run: npm run build

- name: Collect and upload logs
run: |
mkdir -p logs
cp ~/.npm/_logs/*.log logs/
uses: actions/upload-artifact@v3
- name: Deploy to Firebase Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
name: logs
path: logs

- name: Notify failure
if: failure()
run: echo "Build or setup failed. Please check the logs for more details."
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
projectId: course-madj101
channelId: live
22 changes: 18 additions & 4 deletions .github/workflows/setup-environment.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: Setup Environment

on: [push]
on:
push:
branches:
- main

jobs:
setup-environment:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
Expand Down Expand Up @@ -38,7 +41,6 @@ jobs:
echo "# Exercises" > course-materials/exercises/README.md
echo "# Resources" > course-materials/resources/README.md
echo "# Practical Lab Work" > practical-lab-work/README.md
echo '<!DOCTYPE html>
<html lang="en">
<head>
Expand Down Expand Up @@ -156,7 +158,7 @@ footer {

echo '// Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyBkynA5-7Ir9ULqzYsAFEZXvK0717kTub0",
apiKey: "${{ secrets.AISTUDIO_API_KEY }}",
authDomain: "course-madj101.firebaseapp.com",
projectId: "course-madj101",
storageBucket: "course-madj101.appspot.com",
Expand Down Expand Up @@ -245,3 +247,15 @@ function submitQuiz() {
alert("No user logged in!");
}
}' > web-portal/js/scripts.js

- name: Create quiz page
run: |
echo '<!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

0 comments on commit ba760f1

Please sign in to comment.