Simplify deployment workflow and fix package configuration
This commit is contained in:
parent
2b1308688d
commit
7af7c78510
1 changed files with 15 additions and 6 deletions
21
.github/workflows/main_poweron-nyla.yml
vendored
21
.github/workflows/main_poweron-nyla.yml
vendored
|
|
@ -21,7 +21,9 @@ jobs:
|
||||||
cache: 'npm' # Aktiviert Caching für schnellere Builds
|
cache: 'npm' # Aktiviert Caching für schnellere Builds
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: |
|
||||||
|
npm ci
|
||||||
|
npm install express
|
||||||
|
|
||||||
- name: Build React app
|
- name: Build React app
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
@ -31,9 +33,6 @@ jobs:
|
||||||
# Create deployment package with build files and necessary configs
|
# Create deployment package with build files and necessary configs
|
||||||
mkdir deploy
|
mkdir deploy
|
||||||
cp -r dist/* deploy/
|
cp -r dist/* deploy/
|
||||||
cp package.json deploy/
|
|
||||||
cp package-lock.json deploy/
|
|
||||||
cp staticwebapp.config.json deploy/
|
|
||||||
# Create a simple server.js for serving the app
|
# Create a simple server.js for serving the app
|
||||||
echo "const express = require('express');" > deploy/server.js
|
echo "const express = require('express');" > deploy/server.js
|
||||||
echo "const path = require('path');" >> deploy/server.js
|
echo "const path = require('path');" >> deploy/server.js
|
||||||
|
|
@ -42,8 +41,18 @@ jobs:
|
||||||
echo "app.get('/*', function(req, res) { res.sendFile(path.join(__dirname, 'index.html')); });" >> deploy/server.js
|
echo "app.get('/*', function(req, res) { res.sendFile(path.join(__dirname, 'index.html')); });" >> deploy/server.js
|
||||||
echo "const port = process.env.PORT || 8080;" >> deploy/server.js
|
echo "const port = process.env.PORT || 8080;" >> deploy/server.js
|
||||||
echo "app.listen(port, () => console.log('Server running on port', port));" >> deploy/server.js
|
echo "app.listen(port, () => console.log('Server running on port', port));" >> deploy/server.js
|
||||||
# Update package.json to include express and start script
|
# Create a new package.json for deployment
|
||||||
node -e "const pkg = require('./deploy/package.json'); pkg.dependencies.express = '^4.18.2'; pkg.scripts.start = 'node server.js'; require('fs').writeFileSync('./deploy/package.json', JSON.stringify(pkg, null, 2));"
|
echo '{
|
||||||
|
"name": "frontend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"start": "node server.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.18.2"
|
||||||
|
}
|
||||||
|
}' > deploy/package.json
|
||||||
|
|
||||||
- name: 'Deploy to Azure Web App'
|
- name: 'Deploy to Azure Web App'
|
||||||
uses: azure/webapps-deploy@v3
|
uses: azure/webapps-deploy@v3
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue