Skip to content

Commit

Permalink
Make pulumi login respect configuration in Pulumi.yaml (#1299)
Browse files Browse the repository at this point in the history
* Make `pulumi login` respect configuration in `Pulumi.yaml`

Fixes #1120

* Update CHANGELOG.md
  • Loading branch information
tlinhart authored Nov 6, 2024
1 parent 376b437 commit e1fdbd5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## HEAD (Unreleased)

- fix: Make `pulumi login` respect configuration in `Pulumi.yaml`
([#1299](https://github.com/pulumi/actions/pull/1299))

---

## 6.0.0 (2024-09-27)
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ describe('main.login', () => {
});
it('should read self-hosted backend config', async () => {
const cloudUrl = 's3://my_region.aws.com';
await login(cloudUrl);
await login('~', cloudUrl);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith('--non-interactive', 'login', cloudUrl);
expect(spy).toHaveBeenCalledWith('--non-interactive', '--cwd', '~', 'login', cloudUrl);
});
it('should login when no cloud url is provided', async () => {
await login('');
await login('~', '');
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith('--non-interactive', 'login');
expect(spy).toHaveBeenCalledWith('--non-interactive', '--cwd', '~', 'login');
});
});
6 changes: 3 additions & 3 deletions src/#.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as core from '@actions/core';
import * as exec from './libs/exec';
import * as pulumiCli from './libs/pulumi-cli';

export const login = async (cloudUrl: string): Promise<exec.ExecResult> => {
export const login = async (workDir: string, cloudUrl: string): Promise<exec.ExecResult> => {
if (cloudUrl) {
core.info(`Logging into ${cloudUrl}`);
return pulumiCli.run('--non-interactive' ,'login', cloudUrl);
return pulumiCli.run('--non-interactive', '--cwd', workDir, 'login', cloudUrl);
}
core.info("Logging into the Pulumi Cloud backend.");
return pulumiCli.run('--non-interactive', 'login');
return pulumiCli.run('--non-interactive', '--cwd', workDir, 'login');
};
9 changes: 5 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@ const installOnly = async (config: InstallationConfig): Promise<void> => {

const runAction = async (config: Config): Promise<void> => {
await pulumiCli.downloadCli(config.pulumiVersion);
const result = await login(config.cloudUrl);
if (!result.success) {
core.warning(`Failed to login to Pulumi service: ${result.stderr}`);
}

const workDir = resolve(
environmentVariables.GITHUB_WORKSPACE,
config.workDir,
);
core.debug(`Working directory resolved at ${workDir}`);

const result = await login(workDir, config.cloudUrl);
if (!result.success) {
core.warning(`Failed to login to Pulumi service: ${result.stderr}`);
}

const stackArgs: LocalProgramArgs = {
stackName: config.stackName,
workDir: workDir,
Expand Down

0 comments on commit e1fdbd5

Please # to comment.