Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

## HEAD (Unreleased)

**(none)**

---
- feat: Add `working-directory` as an alias for `work-dir` input to improve compatibility with other GitHub Actions
([#1352](https://github.com/pulumi/actions/pull/1352))

## 6.0.1 (2025-01-13)

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The action can be configured with the following arguments:
outside of your individual account. This field is required if a `command` was
specified.

- `work-dir` (optional) - The location of your Pulumi files. Defaults to `./`.
- `work-dir` (optional) - The location of your Pulumi files. Defaults to `./`. Also accepts `working-directory` as an alias to maintain compatibility with other GitHub Actions.

- `cloud-url` - (optional) - the Pulumi backend to login to. This would be the
equivalent of what would be passed to the `pulumi login` command. The action
Expand Down Expand Up @@ -255,6 +255,10 @@ Previously, if `refresh` was true, the action would run `pulumi refresh` before
the desired command. In v6, the `pulumi up` and `pulumi preview` commands will
be run with the `--refresh` flag if `refresh` is true.

Additionally, v6 introduces `working-directory` as an alias for `work-dir` input
to improve compatibility with other GitHub Actions that commonly use
`working-directory` as the standard parameter name.

## Migrating from v4

v5 of the Pulumi Action updates the NodeJS runtime from Node 16 to Node 20.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ inputs:
description: 'Location of your Pulumi files. Defaults to ./'
required: false
default: ./

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to remove this default otherwise getInput will always get this default value?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems so, yeah.

It might be better to remove the default on work-dir.

Following that change, we can deprecate work-dir but keep it as an alias to working-directory for backwards compatibility.

working-directory:
description: 'Alias for work-dir. Location of your Pulumi files. Defaults to ./'
required: false
default: ./
comment-on-pr:
description: 'If true, a comment will be created with results'
required: false
Expand Down
72 changes: 72 additions & 0 deletions src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,76 @@ describe('config.ts', () => {
/Only one of 'pulumi-version' or 'pulumi-version-file' should be provided, got both/,
);
});

it('should use working-directory when work-dir is not provided', async () => {
jest.mock('@actions/core', () => ({
getInput: jest.fn((name: string) => {
switch (name) {
case 'work-dir':
return '';
case 'working-directory':
return '/custom/path';
default:
return defaultConfig[name];
}
}),
getBooleanInput: jest.fn((name: string) => {
return defaultConfig[name];
}),
getMultilineInput: jest.fn((name: string) => {
return defaultConfig[name];
}),
}));
const { makeConfig } = require('../config');
const c = makeConfig();
expect(c.workDir).toBe('/custom/path');
});

it('should use work-dir when working-directory is not provided', async () => {
jest.mock('@actions/core', () => ({
getInput: jest.fn((name: string) => {
switch (name) {
case 'work-dir':
return '/custom/path';
case 'working-directory':
return '';
default:
return defaultConfig[name];
}
}),
getBooleanInput: jest.fn((name: string) => {
return defaultConfig[name];
}),
getMultilineInput: jest.fn((name: string) => {
return defaultConfig[name];
}),
}));
const { makeConfig } = require('../config');
const c = makeConfig();
expect(c.workDir).toBe('/custom/path');
});

it('should prefer work-dir over working-directory when both are provided', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's more transparent for the consumers if the user cannot use both. For example, we can throw an error if the user supplies both.

What do you think?

jest.mock('@actions/core', () => ({
getInput: jest.fn((name: string) => {
switch (name) {
case 'work-dir':
return '/work/dir/path';
case 'working-directory':
return '/working/directory/path';
default:
return defaultConfig[name];
}
}),
getBooleanInput: jest.fn((name: string) => {
return defaultConfig[name];
}),
getMultilineInput: jest.fn((name: string) => {
return defaultConfig[name];
}),
}));
const { makeConfig } = require('../config');
const c = makeConfig();
expect(c.workDir).toBe('/work/dir/path');
});
});
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export function makeConfig() {
}),
stackName: getInput('stack-name', { required: true }),
pulumiVersion: pulumiVersion ?? '^3',
workDir: getInput('work-dir', { required: true }),
workDir: getInput('work-dir') || getInput('working-directory', { required: true }),
secretsProvider: getInput('secrets-provider'),
cloudUrl: getInput('cloud-url'),
githubToken: getInput('github-token'),
Expand Down