actions / actions/toolkit

@actions/exec seems to ignore working-directory workflow setting

Open
#841 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
In an action configured with a working-directory setting, the default CWD of exec.exec() seems to ignore that setting.

To Reproduce
Create a workflow like this:

name: "Docker: Build & Test"

on: [push] # irrelevant
jobs:
  build:
    name: Build Docker image
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: mydir # this bit
    steps:
      - uses: some/action

in a repository with some files in mydir at the root

And an action containing this:

import * as exec from '@actions/exec'
async function run(): Promise<void> {
  await exec.exec('pwd')
  await exec.exec('ls')
}
run()

Expected behavior
The pwd output should reflect the working-directory setting. The ls output should show the contents of that directory.

Additional context
Both the workflow-level and job-level working-directory setting are ignored. It's not clear how to get at that value to set it manually, if it's even possible.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided workflow and the TypeScript calls to @actions/exec.exec('pwd') and exec('ls'), then inspect how the execution context is established. Confirm whether workflow- and job-level working-directory values are available to an action, and document or implement behavior that matches the expected directory output if the toolkit can access them.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
devops, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.