-1

I'm trying to deploy my Node.js application to Azure web app instance. Here are the web app details:

  • Operating System : Linux
  • Runtime stack : Node-20-LTS

Here is my code structure on my local machine (VS Code):

enter image description here

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

enter image description here

For GitHub Linux based agents, these folder names are not same.

2
  • 1
    @AsleshaKantamsetti as you can see in the screenshot: The location of the package.json is in the tictactoe folder. Content of the public folder is only the index.html. Your solution will not work :) Commented May 21 at 8:44
  • @RBT working-directory: ./tictactoe In addition to this change package: . to package: ./tictactoe Commented May 21 at 10:32

1 Answer 1

1

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.

enter image description here

enter image description here

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


enter image description here

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:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Your suggestion of using the Print directory tree step under build job did the trick for me. The root cause was that directory paths in Linux operating system are case-sensitive. The folder structure getting created on the build agent had the folder name in pascal case as TicTacToe. But in my workflow yaml file, I was mentioning working-directory attribute as tictactoe. Since GitHub actions use Linux based build agents, so it was failing to find the directory named tictactoe. After changing the value of working-directory attribute to TicTacToe, it worked like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.