I'm trying to deploy my Node.js application to Azure web app instance. Here are the web app details:
Here is my code structure on my local machine (VS Code):
When I run the GitHub Actions workflow (main_tictactoebharat.yml
) to deploy the Node application, I'm getting below error:
Run npm install Error: An error occurred trying to start process '/usr/bin/bash' with working directory '/home/runner/work/rasik210/rasik210/tictactoe'. No such file or directory
Here is my workflow file:
# 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 - tictactoebharat
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
working-directory: tictactoe
- name: Zip artifact for deployment
run: zip release.zip ./* -r
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-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 #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: Unzip artifact for deployment
run: unzip release.zip
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_2121E0E0CB924E5C844E27BC59D442D1 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_BF9CF6B33E584B7E8CE618857E35D3E6 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_3605AC80CF28413D8D39C856EDB7158E }}
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'tictactoebharat'
slot-name: 'Production'
package: .
Update: After getting the suggestion from Naveen, I checked the folder structure of my GitHub repository. To my astonishment, the casing of folder name containing package.json
file was different on my local machine when compared to GitHub repository.
Folder name on my local machine: tictactoe
Folder name in GitHub repository (Pascal case): TicTacToe
For GitHub Linux based agents, these folder names are not same.
Run npm install Error: An error occurred trying to start process ‘/usr/bin/bash’ with working directory ‘/home/runner/work/rasik210/rasik210/tictactoe’. No such file or directory
The error occurs because the working-directory
you specified in the workflow file for the npm install
step does not exist when the step is executed.
Please check your GitHub repository to make sure that the tictactoe
subfolder is deployed correctly. Sometimes, subfolders may not deploy properly if they contain a .git
file.
You can check your folder structure in the runner by adding lines of the code to your workflow file.
- name: Print directory tree
run: tree -L 3
I have configured the working directory as ./nodeapp
.
Make sure your tictactoe
folder contains package.json
and server.js
files.
Below is my Workflow file for reference:
name: Build and deploy Node.js app to Azure Web App - <AzureWebAppName>
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Print directory tree
run: tree -L 3
- 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
working-directory: ./nodeapp
- name: Zip artifact for deployment
run: zip release.zip ./* -r
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-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
contents: read
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app
- name: Unzip artifact for deployment
run: unzip release.zip
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_2E864077AFA449F590B7683E54A484DA }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_2906505A737B4723846500C863A3491B }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_00486024BC2A4D9583E1B436DE2C1D2C }}
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'kanodeapp21'
slot-name: 'Production'
package: ./nodeapp
Azure Output: