0

I am trying to build a GitHub workflow that deploys my react website and PHP backend to a server (using FTP). The FTP part works.

The problem that i am now facing is, that i need to automatically but my builded react frontend into the file structure with my backend.

Locally i am using Windows and in my project.json i move the builded frontend by using :

"build-webapp:win":  "react-scripts build && RMDIR /S /Q webapp\\html\\static && move build\\static webapp\\html",

That also works.

Since the GitHub workflow is running on ubuntu-latest i implemented the equivalent

"build-webapp:ci":  "react-scripts build && rm -rf /webapp/html/static && mv /build/static /webapp/html"

When i run this on GitHub actions it gives me the following error :

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build-webapp:ci: `react-scripts build  && rm -rf webapp/html/static && mv build/static webapp/html`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build-webapp:ci 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/2021-11-05T12_18_53_579Z-debug.log
Error: Process completed with exit code 1.

I also get the same error when i use the windows command on "windows-latest" in GitHub actions.

The complete Workflow looks like that :

name: Deploy to development
on:
  push:
    branches:
      - devel
jobs:
  deploy:
    runs-on: ubuntu-latest
    name: Build, Test and Deploy
    steps:
      - name: Checkout 
        uses: actions/checkout@v2
        with:
          persist-credentials: false
      - name: Install
        run: npm install
      - name: Build Webapp
        run:  npm run build-webapp:ci
      - name: List /build
        run: ls ./build
      - name: List /webapp
        run: ls ./webapp
      - name: Deploy webapp
        uses: milanmk/actions-file-deployer@master
        with:
          remote-protocol: "sftp"
          remote-host:  ${{ secrets.FTP_SERVER }}
          remote-user: ${{ secrets.FTP_USER }}
          remote-password:  ${{ secrets.FTP_PASSWORD }}
          remote-path: "/development"
          sync: "full"
          local-path: "webapp/"

I am pretty new to the GitHub actions topic, so i hope someone can help me with that.

Thanks

1 Answer 1

1

Okay i solved it by myself, maybe this is helpful for others :

The problem wasn't the rm and mv but that npm warning will be treated as errors here. to disable that add CI=false to the command :

"build-webapp:ci": "CI=false && react-scripts build && rm -rf webapp/html/static && mv build/static webapp/html"

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

Comments

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.