diff --git a/.github/workflows/main_meiszwflz-test-v2.yml b/.github/workflows/main_meiszwflz-test-v2.yml new file mode 100644 index 0000000..b02a80f --- /dev/null +++ b/.github/workflows/main_meiszwflz-test-v2.yml @@ -0,0 +1,62 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy Node.js app to Azure Web App - meiszwflz-test-v2 + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js version + uses: actions/setup-node@v3 + with: + node-version: '18.x' + + - name: Zip artifact for deployment + run: zip release.zip ./* -r + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v3 + with: + name: node-app + path: release.zip + + - name: npm install, build, and test + run: | + npm install + npm run build --if-present + npm run test --if-present + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v3 + with: + name: node-app + + - name: 'Deploy to Azure Web App' + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'meiszwflz-test-v2' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_291038A7A98943A8AA7C81155066199E }} + package: release.zip + + - name: Delete zip file + run: rm release.zip diff --git a/.husky/commit-msg b/.husky/commit-msg old mode 100644 new mode 100755 diff --git a/.husky/pre-commit b/.husky/pre-commit old mode 100644 new mode 100755 diff --git a/package.json b/package.json index 3b5d138..b95651b 100644 --- a/package.json +++ b/package.json @@ -22,20 +22,20 @@ "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json", - "prepare": "husky install", + "prepare": "./prepare.sh", "prepack": "npm run check-lint && npm run check-format" }, "dependencies": { "@nestjs/common": "^10.0.0", "@nestjs/core": "^10.0.0", "@nestjs/platform-express": "^10.0.0", + "@nestjs/cli": "^10.0.0", "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1" }, "devDependencies": { "@commitlint/cli": "^18.4.3", "@commitlint/config-conventional": "^18.4.3", - "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", "@types/express": "^4.17.17", @@ -74,5 +74,8 @@ ], "coverageDirectory": "../coverage", "testEnvironment": "node" + }, + "config": { + "environment": "development" } } diff --git a/prepare.sh b/prepare.sh new file mode 100755 index 0000000..e5fa3db --- /dev/null +++ b/prepare.sh @@ -0,0 +1,4 @@ +#!/bin/sh +if [ -d './node_modules/husky' ]; then + npx husky install +fi \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 13cad38..cbaad69 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,10 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; +const port = process.env.PORT || 3000; + async function bootstrap() { const app = await NestFactory.create(AppModule); - await app.listen(3000); + await app.listen(port); } bootstrap(); diff --git a/web.config b/web.config new file mode 100644 index 0000000..8987fcf --- /dev/null +++ b/web.config @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file