From e7f8f3753079de8afcd75ebce3232286e61086bc Mon Sep 17 00:00:00 2001 From: Raydo Matthee Date: Sun, 2 Jun 2024 04:24:43 +0200 Subject: [PATCH] Update deploy.yml --- .github/workflows/deploy.yml | 49 +++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 22d106b..e3a21ea 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v3 @@ -42,6 +42,53 @@ jobs: }' > firebase.json fi + - 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 env: FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}