Github actions EACCES: permission denied on yarn install

Viewed 2842

Can anyone please help me through this issue. On App Deployment through Github actions I'm getting this error on building react app setction.

Run yarn build
yarn run v1.22.5
$ react-scripts build
Creating an optimized production build...
Failed to compile.

EACCES: permission denied, mkdir '/home/runner/work/COVID-19-Tracker-App/COVID-19-Tracker-App/node_modules/.cache'


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

My workflow contains this and I'm getting this error on "Build React App" section.

# This is a basic workflow to help you get started with Actions

name: React App Deployment

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

# 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: Install Node.Js
        uses: actions/setup-node@v2-beta
        with:
          node-version: 12
      
      - name: Install Yarn
        uses: borales/actions-yarn@v2.0.0
        with:
          cmd: install # will run `yarn install` command
          
      - name: Build React App
        run: yarn build
        
      - name: Install Surge
        run: npm install --global surge
        
      - name: Deploy to Surge
        run: surge ./build covid-19_tracker_app.surge.sh --token ${{secrets.Surge_Token}}
3 Answers

Use sudo yarn build instead of yarn build.

You should follow that, use cmd not use run

name: CI
on: [push]
jobs:
  build:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: borales/actions-yarn@v2.0.0
        with:
          cmd: install # will run `yarn install` command
      - uses: borales/actions-yarn@v2.0.0
        with:
          cmd: build # will run `yarn build` command

https://github.com/marketplace/actions/github-action-for-yarn

I had similar problems in github actions, it turned out that some previous step caused a directory to be owned by the root user.

sudo chown $USER invoice-app/build

fixed it.

The ssh debug action was super helpful in finding the problem, I highly recommend it if you're having these kinds of problems.

Related