diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c1bade0..1e6b4e0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.md b/README.md index 4c6a0119..39380dab 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/action.yml b/action.yml index 9461a949..eb42e9c7 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,10 @@ inputs: description: 'Location of your Pulumi files. Defaults to ./' required: false default: ./ + 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 diff --git a/src/__tests__/config.test.ts b/src/__tests__/config.test.ts index 81418498..ae824e94 100644 --- a/src/__tests__/config.test.ts +++ b/src/__tests__/config.test.ts @@ -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 () => { + 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'); + }); }); diff --git a/src/config.ts b/src/config.ts index 3f905efb..3dae1303 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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'),