From 15586570b1f6323d45d17d7140e90d9ecfabb843 Mon Sep 17 00:00:00 2001 From: Sagar Rajak <65167758+Sagarrajak01@users.noreply.github.com> Date: Mon, 16 Mar 2026 17:33:40 +0530 Subject: [PATCH 1/2] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/main_todowebapp.yml | 65 +++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/main_todowebapp.yml diff --git a/.github/workflows/main_todowebapp.yml b/.github/workflows/main_todowebapp.yml new file mode 100644 index 0000000..2e7618b --- /dev/null +++ b/.github/workflows/main_todowebapp.yml @@ -0,0 +1,65 @@ +# 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 - todowebapp + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read #This is required for actions/checkout + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js version + uses: actions/setup-node@v3 + with: + node-version: '20.x' + + - name: npm install, build, and test + run: | + npm install + npm run build --if-present + npm run test --if-present + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v4 + with: + name: node-app + path: . + + deploy: + runs-on: ubuntu-latest + needs: build + permissions: + id-token: write #This is required for requesting the JWT + contents: read #This is required for actions/checkout + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: node-app + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_75A14F9C328D47B08B58CBC222D3DFBD }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_BDB2E7EDDC1D4A56B646FA78FBC7B7BF }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_516375029F6B42C2A83CCBD564858F93 }} + + - name: 'Deploy to Azure Web App' + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: 'todowebapp' + slot-name: 'Production' + package: . + \ No newline at end of file From e9a631e0685f4d69799a3d5709760e67f7852172 Mon Sep 17 00:00:00 2001 From: Sagar Rajak <65167758+Sagarrajak01@users.noreply.github.com> Date: Mon, 16 Mar 2026 19:11:41 +0530 Subject: [PATCH 2/2] Document GitHub Actions deployment process Added GitHub Actions deployment instructions to README. --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/README.md b/README.md index a5ab741..c29db03 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ products: - azure-app-service - azure-monitor - azure-pipelines +- github-actions urlFragment: todo-nodejs-mongo name: React Web App with Node.js API and MongoDB on Azure description: A complete ToDo app on Azure App Service with Node.js API and Azure Cosmos API for MongoDB for storage. Uses Azure Developer CLI (azd) to build, deploy, and monitor @@ -54,6 +55,65 @@ azd init --template Azure-Samples/todo-nodejs-mongo azd up ``` +## Deployment via GitHub Actions (Cloud-only) + +If you want to deploy directly from GitHub without installing tools locally, configure GitHub Actions as follows. + +### 1. Generate Azure Credentials + +Run the following command in **Azure Cloud Shell**: + +```bash +az ad sp create-for-rbac --name "github-auth-sp" --role contributor --scopes /subscriptions/ --sdk-auth +``` + +Replace `` with your Azure Subscription ID. +The command returns a JSON credential. + +--- + +### 2. Add GitHub Secret + +Open your repository and navigate to: + +**Settings → Secrets and variables → Actions** + +Create a **New repository secret**: + +``` +Name: AZURE_CREDENTIALS +Value: +``` + +--- + +### 3. Add GitHub Variables + +Go to **Settings → Secrets and variables → Variables** and add: + +``` +AZURE_SUBSCRIPTION_ID = +AZURE_LOCATION = centralindia +AZURE_ENV_NAME = todo-node-env +``` + +--- + +### 4. Run Deployment + +Trigger the workflow by pushing a commit: + +```bash +git add . +git commit -m "trigger deployment" +git push origin main +``` + +Or run it manually from: + +**GitHub → Actions → Run workflow** + + ### Application Architecture This application utilizes the following Azure resources: