Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional working_directory to Workflow Steps #1013

Open
osterman opened this issue Feb 4, 2025 · 0 comments
Open

Add optional working_directory to Workflow Steps #1013

osterman opened this issue Feb 4, 2025 · 0 comments

Comments

@osterman
Copy link
Member

osterman commented Feb 4, 2025

Describe the Feature

Steps in a workflow may need to execute from different locations.
Rather than put this common logic into the script portion of the command, we should support a working_directory setting.

Relative paths should be relative to the Atmos base directory. (aka base-dir). This keeps directory locations straightforward and determinisitc.

Expected Behavior

Setting the working_directory, causes atmos to change directory into this location before executing the commands. If the directory does not exist, atmos exits with a clear error message.

Use Case

  • Run some raw terraform commands (e.g. terraform import) inside of a component directory.
  • Run some commands in /tmp (e.g. to download files and unpack them)

Describe Ideal Solution

workflows:
  test-1:
    description: "Test workflow"
    steps:
      - command: wget https://file-examples.com/wp-content/uploads/2017/02/zip_2MB.zip
        name: step1
        type: shell
        working_directory: /tmp
      - command: unzip zip_2MB.zip
        working_directory: /tmp
        type: shell

Alternatively, support a working_directory for the entire workflow.

workflows:
  test-1:
    description: "Test workflow"
    working_directory: /tmp
    steps:
      - command: wget https://file-examples.com/wp-content/uploads/2017/02/zip_2MB.zip
        name: step1
        type: shell

      - command: unzip zip_2MB.zip
        type: shell

With both options being able to be mixed and matched.

Alternatives Considered

We could run cd /some/path as part of the command step. If the workflow command doesn't properly handle exit codes in the script, then it could proceed to run other commands causing damage.

Additional Context

No response

@osterman osterman changed the title Add Support for Optional working_directory for Workflow Steps Add optional working_directory to Workflow Steps Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant