Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github's action is not building react application

When I build (npm run build "scripts": { "build": "react-scripts build --passWithNoTests" }

) project on pc, it successfully builds. But when I push changes, the building process fails on github

> [email protected] build /home/runner/work/project/project
> react-scripts build --passWithNoTests

Creating an optimized production build...

Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.

Failed to compile.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build --passWithNoTests`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2020-08-17T06_51_55_527Z-debug.log
##[error]Process completed with exit code 1.

It's yml file

name: Node.js CI
on:
  push:
    branches: [ test ]
  pull_request:
    branches: [ test ]

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x, 12.x, 14.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
      
    - name: clean cache
      run: npm cache clean --force
    - name: install
      run: npm ci
    - name: npm install
      run: npm install
    - name: build
      run: npm run test --if-present

how can I do it?

like image 471
Vladimir Melkumyan Avatar asked Aug 17 '20 06:08

Vladimir Melkumyan


1 Answers

GitHub Actions set CI environment variable automatically with true . Treating warnings as errors because of it. You can try like below.

- name: build
  run: npm run test --if-present
  env:
     CI: false

Happy automations!

like image 147
Gazi Dizdaroglu Avatar answered Nov 11 '22 11:11

Gazi Dizdaroglu