Wajid Hussain
Wajid Hussain

Reputation: 11

auto deploy GitHub repo using GitHub actions

I have created an action in Github Actions for deploying a React App Repo on surge.sh. In action, all jobs are completed successfully but the job for deploying on surge is going to fail by giving an error

"Run surge ./build http://reactapp-saim.surge.sh --token ***
   Running as [email protected] (Student)
   **Aborted - No such file or directory: ./build**
Error: Process completed with exit code 1."

my code for this job is

    name: React app deploy

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]


  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Runs a single command using the runners shell
      - name: installing node 
        uses: actions/setup-node@v2
        with: 
          node-version: '14'
          
      - name: GitHub Action for Yarn
        # You may pin to the exact commit or the version.
        # uses: Borales/actions-yarn@4965e1a0f0ae9c422a9a5748ebd1fb5e097d22b9
        uses: Borales/[email protected]
        with:
          # Yarn command
          cmd: install
          
      - name: creating build
        run: npm build # npm build
        
      - name: installing surge
        run: npm install -g surge
        
      - name: deploying with surge
        run: surge ./build http://reactapp-saim.surge.sh --token ${{ secrets.SURGE_TOKEN}}

Upvotes: 1

Views: 366

Answers (1)

This code is not generating the bundle correctly.

- name: creating build
    run: npm build # npm build

You need to run npm run build or npm run-script build So your step will look as follow:

- name: creating build
        run: npm run build

Upvotes: 1

Related Questions