Reputation: 1389
Trying to deploy react app to the azure web app using GitHub action & resources will be created dynamically under a single resource group which defaults to asgithub-RG
using service principal account as a contributor to asgithub-RG
resource group
Github action
name: Deploy Pull Request to Azure Web App
on:
pull_request:
branches: [ "develop" ]
types: [opened, synchronize, closed]
workflow_dispatch:
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }} # get branch name from pull request
PR_NUMBER: ${{ github.event.pull_request.number }}
AZURE_WEBAPP_NAME: ${{ github.event.pull_request.head.repo.name }}-${{ github.event.pull_request.head.ref }} # add GTCRM- prefix to branch name
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: '18-lts' # set this to the node version to use
RESOURCE_GROUP: 'asgithub-RG'
permissions:
contents: read
pull-requests: write
actions: write
jobs:
pre-build:
if: github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login via Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# Create a new resource group to hold the deployment slot
- name: Create App service plan
uses: Azure/cli@v1
with:
inlineScript: |
az appservice plan create --name ${{ env.AZURE_WEBAPP_NAME }}-${{ env.PR_NUMBER }}-plan --resource-group ${{ env.RESOURCE_GROUP }} --sku B1 --is-linux
# Set the deployment slot's app setting to point to the staging slot
- name: Set app setting
uses: Azure/cli@v1
with:
inlineScript: |
az webapp create --resource-group ${{ env.RESOURCE_GROUP }} --plan ${{ env.AZURE_WEBAPP_NAME }}-${{ env.PR_NUMBER }}-plan --name ${{ env.AZURE_WEBAPP_NAME }}-${{ env.PR_NUMBER }} --runtime "NODE:${{ env.NODE_VERSION }}" --output table
build:
runs-on: ubuntu-latest
needs: pre-build
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18.4.0
cache: 'npm'
# Cache node_modules
- name: Cache node_modules
uses: actions/[email protected]
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
# Install dependencies
- name: Install Dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
npm install
npm run ci --if-present
# tar the build folder
- name: Zip Package
run: |
zip -r node-app.zip .
# Upload the zip file to the deployment slot
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: node-app
path: node-app.zip
# Deploy the zip file to the deployment slot
deploy:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
needs: build
environment:
name: 'Development'
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: node-app
# #Unpack the artifact
# - name: Unzip artifact
# run: unzip node-app.zip
- name: Login via Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Deploy to Azure WebApp'
id: deploy-to-webapp
uses: Azure/[email protected]
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}-${{ env.PR_NUMBER }}
package: node-app.zip
Problem 1: I executed from one GitHub repo all 7 steps are executing fine in GitHub and deployment is getting failed in the azure web app
logs
2022-12-10T10:54:48.581727176Z: \[INFO\] \____\_
2022-12-10T10:54:48.581757676Z: \[INFO\] / \_ \\ \_________\_ \________\_ \___\_
2022-12-10T10:54:48.581762376Z: \[INFO\] / /_\\ \\_\_\_ / | \_ \_\_ \_/ \_\_ \\
2022-12-10T10:54:48.581765977Z: \[INFO\] / | / /| | /| | /\\ \__\_/
2022-12-10T10:54:48.581769477Z: \[INFO\] \____|__ /_\___\_ \____/ |__| \__\_ \>
2022-12-10T10:54:48.581773177Z: \[INFO\] / / /
2022-12-10T10:54:48.581776477Z: \[INFO\] A P P S E R V I C E O N L I N U X
2022-12-10T10:54:48.581779777Z: \[INFO\]
2022-12-10T10:54:48.581782777Z: \[INFO\] Documentation: http://aka.ms/webapp-linux
2022-12-10T10:54:48.581785977Z: \[INFO\] NodeJS quickstart: https://aka.ms/node-qs
2022-12-10T10:54:48.581788977Z: \[INFO\] NodeJS Version : v18.12.0
2022-12-10T10:54:48.581792277Z: \[INFO\] Note: Any data outside '/home' is not persisted
2022-12-10T10:54:48.581795477Z: \[INFO\]
2022-12-10T10:54:49.216708277Z: \[INFO\] Starting OpenBSD Secure Shell server: sshd.
2022-12-10T10:54:49.446358441Z: \[INFO\] Starting periodic command scheduler: cron.
2022-12-10T10:54:49.598691233Z: \[INFO\] Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2022-12-10T10:54:49.606104102Z: \[INFO\] Could not find operation ID in manifest. Generating an operation id...
2022-12-10T10:54:49.606179104Z: \[INFO\] Build Operation ID: 5aceb568-51a8-4ee6-9f9d-835f90d52e7a
2022-12-10T10:54:50.732891663Z: \[INFO\] Environment Variables for Application Insight's IPA Codeless Configuration exists..
2022-12-10T10:54:50.895699980Z: \[INFO\] Writing output script to '/opt/startup/startup.sh'
2022-12-10T10:54:51.128069973Z: \[INFO\] Running #!/bin/sh
2022-12-10T10:54:51.128097374Z: \[INFO\]
2022-12-10T10:54:51.128102674Z: \[INFO\] # Enter the source directory to make sure the script runs where the user expects
2022-12-10T10:54:51.128106774Z: \[INFO\] cd "/home/site/wwwroot"
2022-12-10T10:54:51.128110674Z: \[INFO\]
2022-12-10T10:54:51.128114474Z: \[INFO\] export NODE_PATH=/usr/local/lib/node_modules:$NODE_PATH
2022-12-10T10:54:51.128118574Z: \[INFO\] if \[ -z "$PORT" \]; then
2022-12-10T10:54:51.128122474Z: \[INFO\] export PORT=8080
2022-12-10T10:54:51.128126674Z: \[INFO\] fi
2022-12-10T10:54:51.128130374Z: \[INFO\]
2022-12-10T10:54:51.215962971Z: \[INFO\] npm start
2022-12-10T10:54:53.801869544Z: \[ERROR\] npm info it worked if it ends with ok
2022-12-10T10:54:53.803157767Z: \[ERROR\] npm info using [email protected]
2022-12-10T10:54:53.812627941Z: \[ERROR\] npm info using [email protected]
2022-12-10T10:54:55.390189353Z: \[ERROR\] npm info lifecycle [email protected]\~prestart: [email protected]
2022-12-10T10:54:55.449869038Z: \[ERROR\] npm info lifecycle [email protected]\~start: [email protected]
2022-12-10T10:54:55.481953221Z: \[INFO\]
2022-12-10T10:54:55.482000722Z: \[INFO\] \> [email protected] start /home/site/wwwroot
2022-12-10T10:54:55.482007922Z: \[INFO\] \> react-scripts start
2022-12-10T10:54:55.482023422Z: \[INFO\]
2022-12-10T10:54:57.161168776Z: \[ERROR\] node:internal/modules/cjs/loader:998
2022-12-10T10:54:57.161201276Z: \[ERROR\] throw err;
2022-12-10T10:54:57.161206076Z: \[ERROR\] ^
2022-12-10T10:54:57.161209576Z: \[ERROR\]
2022-12-10T10:54:57.161212977Z: \[ERROR\] Error: Cannot find module '../scripts/start'
2022-12-10T10:54:57.161216377Z: \[ERROR\] Require stack:
2022-12-10T10:54:57.161220077Z: \[ERROR\] - /home/site/wwwroot/node_modules/.bin/react-scripts
2022-12-10T10:54:57.161223477Z: \[ERROR\] at Module.\_resolveFilename (node:internal/modules/cjs/loader:995:15)
2022-12-10T10:54:57.161227477Z: \[ERROR\] at Function.resolve (node:internal/modules/cjs/helpers:109:19)
2022-12-10T10:54:57.161235677Z: \[ERROR\] at Object.\<anonymous\> (/home/site/wwwroot/node_modules/.bin/react-scripts:31:23)
2022-12-10T10:54:57.161240177Z: \[ERROR\] at Module.\_compile (node:internal/modules/cjs/loader:1159:14)
2022-12-10T10:54:57.161243577Z: \[ERROR\] at Module.\_extensions..js (node:internal/modules/cjs/loader:1213:10)
2022-12-10T10:54:57.161246977Z: \[ERROR\] at Module.load (node:internal/modules/cjs/loader:1037:32)
2022-12-10T10:54:57.161250277Z: \[ERROR\] at Module.\_load (node:internal/modules/cjs/loader:878:12)
2022-12-10T10:54:57.161253777Z: \[ERROR\] at Function.executeUserEntryPoint \[as runMain\] (node:internal/modules/run_main:81:12)
2022-12-10T10:54:57.161257177Z: \[ERROR\] at node:internal/main/run_main_module:23:47 {
2022-12-10T10:54:57.161260578Z: \[ERROR\] code: 'MODULE_NOT_FOUND',
2022-12-10T10:54:57.161263878Z: \[ERROR\] requireStack: \[ '/home/site/wwwroot/node_modules/.bin/react-scripts' \]
2022-12-10T10:54:57.161267278Z: \[ERROR\] }
2022-12-10T10:54:57.171300295Z: \[ERROR\]
2022-12-10T10:54:57.171322096Z: \[ERROR\] Node.js v18.12.0
2022-12-10T10:54:57.240925304Z: \[ERROR\] npm info lifecycle [email protected]\~start: Failed to exec start script
2022-12-10T10:54:57.262303367Z: \[ERROR\] npm ERR! code ELIFECYCLE
2022-12-10T10:54:57.270736750Z: \[ERROR\] npm ERR! errno 1
2022-12-10T10:54:57.331226561Z: \[ERROR\] npm ERR! [email protected] start: `react-scripts start`
2022-12-10T10:54:57.331244961Z: \[ERROR\] npm ERR! Exit status 1
2022-12-10T10:54:57.331249462Z: \[ERROR\] npm ERR!
2022-12-10T10:54:57.331261062Z: \[ERROR\] npm ERR! Failed at the [email protected] start script.
2022-12-10T10:54:57.331264962Z: \[ERROR\] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-12-10T10:54:57.343324323Z: \[ERROR\] npm timing npm Completed in 4353ms
2022-12-10T10:54:57.343341624Z: \[ERROR\]
2022-12-10T10:54:57.343346224Z: \[ERROR\] npm ERR! A complete log of this run can be found in:
2022-12-10T10:54:57.343350024Z: \[ERROR\] npm ERR! /root/.npm/\_logs/2022-12-10T10_54_57_310Z-debug.log
Problem 2: Just to try with create react app i will same github action and credentials it is failing after login on step 2
logs
Starting script execution via docker image mcr.microsoft.com/azure-cli:2.42.0
ERROR: (ResourceNotFound) The Resource 'Microsoft.Web/serverFarms/azwebappci-feature' under resource group 'azwebapp' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Code: ResourceNotFound
Message: The Resource 'Microsoft.Web/serverFarms/azwebappci-feature' under resource group 'azwebapp' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
Error: Error: az cli script failed.
cleaning up container...
MICROSOFT_AZURE_CLI_1670667478073_CONTAINER
Error: az cli script failed.
Expectation ==>
As a workaround, I think of App service container deployment or host build folder on Static website .
Upvotes: 0
Views: 810
Reputation: 65411
Based on the error message it appears that the problem is that it cannot find the manifest file:
Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
I would do the following to isolate the problem:
Upvotes: 0