added diagnostics logs #45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to Azure App Service | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| env: | |
| AZURE_WEBAPP_NAME: worrybox-backend # Set this to your app name | |
| AZURE_WEBAPP_PACKAGE_PATH: './backend' # Set this to the path to your backend | |
| NODE_VERSION: '18' # Set this to the node version to use | |
| jobs: | |
| build-and-deploy: | |
| name: Build and Deploy | |
| runs-on: ubuntu-latest | |
| environment: production | |
| steps: | |
| - name: 'Checkout GitHub Action' | |
| uses: actions/checkout@v4 | |
| - name: Setup Node ${{ env.NODE_VERSION }} Environment | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: backend/package-lock.json | |
| - name: 'Install dependencies' | |
| run: | | |
| cd backend | |
| npm ci | |
| - name: 'Build application' | |
| run: | | |
| cd backend | |
| npm run build | |
| - name: 'Generate Prisma Client' | |
| run: | | |
| cd backend | |
| npx prisma generate | |
| env: | |
| DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
| - name: 'Run tests' | |
| run: | | |
| cd backend | |
| npm run test:ci | |
| env: | |
| NODE_ENV: test | |
| DATABASE_URL: ${{ secrets.DATABASE_URL_TEST }} | |
| JWT_SECRET: ${{ secrets.JWT_SECRET }} | |
| JWT_REFRESH_SECRET: ${{ secrets.JWT_REFRESH_SECRET }} | |
| - name: 'Deploy to Azure WebApp' | |
| uses: azure/webapps-deploy@v2 | |
| with: | |
| app-name: ${{ env.AZURE_WEBAPP_NAME }} | |
| publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | |
| package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} | |
| - name: 'Health Check' | |
| run: | | |
| sleep 30 | |
| curl -f https://${{ env.AZURE_WEBAPP_NAME }}.azurewebsites.net/api/health || exit 1 | |
| echo "Deployment successful!" |