Github actions working-directory incorrectly documented? 'Unexpected value 'working-directory''

Hi I’m setting up the new syntax for github actions and as part of the workflow the steps or jobs need to be run in a subfolder, thinking the easiest way to do this is by using the working-directory option documented here.

https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsworking-directory

Assuming placement is correct I have a filed that follows this structure

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      [other steps]
      - name: yarn install, build, and test
        working-directory: gatsby # Error Line Referred to by error response
        run: |
          yarn install
          yarn run build --if-present
          yarn lint

 Where i get the following error

Your workflow file was invalid: .github/workflows/gatsby-ci.yml (Line: 24, Col: 9): Unexpected value 'working-directory'

Any clarification on the matter will be much appreciated.

Thanks in advance.

7 Likes

Hey @yoroshikun,

I’m wondering if this is a syntax issue, could you try:

working-directory: ./gatsby

I am getting the same error with the following file:

name: Continious Integration
on: [pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Execute tests
      uses: agemooij/github-actions-sbt@master
      with:
        args: test
      working-directory: ./kafka-fs2

I am also getting the same error with the following workflow.

name: Infrastructure
on: [push,pull_request]

jobs:
  preview:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Preview
        uses: pulumi/actions
        working-directory: ./infrastructure
        with:
          args: preview
        env:
          PULUMI_CI: pr
        secrets:
          - PULUMI_ACCESS_TOKEN
          - GOOGLE_CREDENTIALS

Would greatly appreciate any guidance on the correct syntax.

This workflow works fine for me, but I would like to know if it’s possible to simplify this by setting the working-directory for a set of steps.

name: frontend

on: [push]

jobs:

  test:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@master

    - name: Set Node.js 10.x
      uses: actions/setup-node@master
      with:
        version: 10.x

    - name: Install dependencies
      working-directory: ./frontend
      run: |
        npm install

    - name: Run lint
      working-directory: ./frontend
      run: |
        npm run lint
7 Likes

It seems like ‘working-directory’ does not work in combination with ‘uses’

8 Likes

From my understanding, an action is reusable/isolated code. Therefore there is no working directory for a step that uses an action (because an action can be pretty much anything). In regards to a custom action, you probably have to give the action an argument and pass a path.

3 Likes

I also have the same error but no idea.

Haha~, https://github.com/actions/checkout reslove it.

name: Deploy Gatsby Website

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Set Node.js 10.x
        uses: actions/setup-node@master
        with:
          node-version: 10.x

      - name: Build site assets
        working-directory: ${{ github.workspace }}
        run: ls -la

      - name: Install dependencies
        working-directory: docs
        run: |
          npm install

      - name: Build
        working-directory: docs
        run: |
          npm run build

      - name: Deploy
        working-directory: docs
        run: |
          npm run docs
7 Likes

I really expect they add a decent way to declare the working directory for a set of steps. God knows that looks ugly.

1 Like