Skip to content

Update setup-environment.yml #22

Update setup-environment.yml

Update setup-environment.yml #22

name: Build and Deploy
on:
push:
branches:
- main
jobs:
build-and-deploy:
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 package.json if it doesn't exist
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",
"build": "webpack --config webpack.config.js"
},
"author": "Raydo Matthee",
"license": "ISC",
"dependencies": {
"webpack": "^5.0.0",
"webpack-cli": "^4.0.0"
}
}' > package.json
fi
- name: Create webpack.config.js if it doesn't exist
run: |
if [ ! -f webpack.config.js ]; then
echo '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"
};' > webpack.config.js
fi
- name: Install dependencies
run: |
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
- name: Build project
run: npm run build
- name: Deploy to Firebase Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_COURSE_MADJ101 }}
projectId: course-madj101
channelId: live