Home > Net >  How to use working-directory in GitHub actions?
How to use working-directory in GitHub actions?

Time:05-30

I'm trying to set-up and run a GitHub action in a nested folder of the repo.

I thought I could use working-directory, but if I write this:

jobs:
  test-working-directory:
    runs-on: ubuntu-latest
    name: Test
    defaults:
      run:
        working-directory: my_folder
    steps:
      - run: echo test

I get an error:

Run echo test
echo test
shell: /usr/bin/bash -e {0}
Error: An error occurred trying to start process '/usr/bin/bash' with working directory '/home/runner/work/my_repo/my_repo/my_folder'. No such file or directory

I notice my_repo appears twice in the path of the error.

Here is the run on my repo, where:

  • my_repo = novade_flutter_packages
  • my_folder = packages

What am I missing?

CodePudding user response:

You didn't check out the repository on the second job.

Each job runs on a different instance, so you have to checkout it separately for each one of them.

  • Related