Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run my CI steps in a specific folder in github action

I have a golang repo with a react client. I want to setup up CI using github actions for my client. The React client is inside the client folder in the workspace. I have written the following workflow

name : Node.js CI

on: [push, pull_request]

jobs:

  build:
    name: build
    runs-on: ubuntu-latest
    steps:

    - uses: actions/checkout@v2 
      with:
        path: client
    - name: Set up Node.js
      uses: actions/setup-node@v1
      with:
        node-version: 12.x

    - run: yarn install

    - run: yarn build

But on committing it shows the following error

 Run yarn build1s
##[error]Process completed with exit code 1.
Run yarn build
yarn run v1.21.1
error Couldn't find a package.json file in "/home/runner/work/evential/evential"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
##[error]Process completed with exit code 1

The snippet

- uses: actions/checkout@v2 
      with:
        path: client

doesn't make the steps following run inside the client folder.

Need help. Thanks in advance.

like image 566
ankitjena Avatar asked Feb 10 '20 07:02

ankitjena


People also ask

What directory do GitHub Actions run in?

GitHub Actions uses YAML syntax to define the workflow. Each workflow is stored as a separate YAML file in your code repository, in a directory named .github/workflows . You can create an example workflow in your repository that automatically triggers a series of commands whenever code is pushed.

Do GitHub Actions steps run in parallel?

Not at this moment. Only jobs can run in parallel, but steps always run sequentially.


1 Answers

You can use the working-directory keyword in a run step. See the documentation here.

    - run: yarn install
      working-directory: client

    - run: yarn build
      working-directory: client
like image 97
peterevans Avatar answered Oct 19 '22 02:10

peterevans