This file contains 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: Build and deploy Node.js app to Azure Web App - Vibes-only | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build-and-deploy: | |
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: Build frontend | |
run: | | |
cd client | |
npm install | |
npm run build | |
- name: Zip frontend build for deployment | |
run: zip -r frontend-build.zip ./client/dist | |
- name: Upload frontend build artifact for deployment | |
uses: actions/upload-artifact@v3 | |
with: | |
name: frontend-build | |
path: frontend-build.zip | |
- name: Start Node.js server | |
run: | | |
cd server | |
npm install | |
node index.js & | |
- name: Zip server for deployment | |
run: zip -r server.zip ./server | |
- name: Upload server artifact for deployment | |
uses: actions/upload-artifact@v3 | |
with: | |
name: node-server | |
path: server.zip | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build-and-deploy | |
environment: | |
name: "production" | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
permissions: | |
id-token: write #This is required for requesting the JWT | |
steps: | |
- name: Download frontend build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: frontend-build | |
- name: Download server artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: node-server | |
- name: Unzip artifacts for deployment | |
run: | | |
unzip frontend-build.zip | |
unzip server.zip | |
- name: Login to Azure | |
uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.__clientidsecretname__ }} | |
tenant-id: ${{ secrets.__tenantidsecretname__ }} | |
subscription-id: ${{ secrets.__subscriptionidsecretname__ }} | |
- name: Deploy to Azure Web App | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: "Vibes-only" | |
slot-name: "production" | |
package: . |