Act: working-directory syntax use environment value is not working

Created on 9 Dec 2020  路  2Comments  路  Source: nektos/act

Hello!
First of all, thank you very much for making this great tool. 馃槃

I tried to perform github action in the local environment using the tool, but there was a problem.
I want to add the working-directory value to the env and inject it into the required step.
Example

jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      WORKING_DIRECTORY: ./services/test

   steps:
      - name: test
         working-directory: ${{env.WORKING_DIRECTORY}}
         run: ls -R

The github action actually works very well, but an error occurs in the act tool.

Error Message:

/github/workflow/5: line 1: ${{env.WORKING_DIRECTORY}}: bad substitution

Is there any other way to use this problem or can it be improved?

Thank you.

Most helpful comment

so actually this is the same issue as https://github.com/nektos/act/issues/181, https://github.com/nektos/act/issues/337, https://github.com/nektos/act/issues/315, https://github.com/nektos/act/issues/435 馃槃

If I change the workflow yml from:

    defaults:
      run:
        working-directory: infrastructure/${{ matrix.environment }}

to:

    defaults:
      run:
        working_directory: infrastructure/${{ matrix.environment }}

(so working-directory to working_directory) the error goes away 馃挭

Of course that breaks the workflow from running, but at least it, we now know the interpolation / hyphen errors occurs with the YAML processing, apparently when there is a variable used.

All 2 comments

Ha, took me a while to find this issue, having exactly the same problem. Using working-directory to do prd/acc/dev etc.

so actually this is the same issue as https://github.com/nektos/act/issues/181, https://github.com/nektos/act/issues/337, https://github.com/nektos/act/issues/315, https://github.com/nektos/act/issues/435 馃槃

If I change the workflow yml from:

    defaults:
      run:
        working-directory: infrastructure/${{ matrix.environment }}

to:

    defaults:
      run:
        working_directory: infrastructure/${{ matrix.environment }}

(so working-directory to working_directory) the error goes away 馃挭

Of course that breaks the workflow from running, but at least it, we now know the interpolation / hyphen errors occurs with the YAML processing, apparently when there is a variable used.

Was this page helpful?
0 / 5 - 0 ratings