Here is a workflow file that resolved my issue. don't forget to set "SCM_DO_BUILD_DURING_DEPLOYMENT = true" in web app environment variables on Azure:
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: '20.x'
- name: Install dependencies
run: npm install
- name: Build the React app
run: npm run build
- name: Zip the build directory for deployment
run: zip -r release.zip ./*
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: react-app
path: release.zip
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write
steps:
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: react-app
- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZUREAPPSERVICE_}}
tenant-id: ${{ secrets.AZUREAPPSERVICE }}
subscription-id: ${{ secrets.AZUREAPPSERVICE }}
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'web-app-name'
slot-name: 'Production'
package: release.zip