Skip to content

Commit 73ceb51

Browse files
authored
move pre cleanup to main and add pre-if and post-if (#484)
1 parent ffd504a commit 73ceb51

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ branding:
3939
color: 'blue'
4040
runs:
4141
using: 'node20'
42-
pre: 'lib/cleanup/index.js'
4342
main: 'lib/main/index.js'
43+
post-if: (!env.AZURE_LOGIN_POST_CLEANUP || env.AZURE_LOGIN_POST_CLEANUP != 'false')
4444
post: 'lib/cleanup/index.js'

src/main.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import * as core from '@actions/core';
2-
import { setUserAgent } from './common/Utils';
2+
import { cleanupAzCLIAccounts, cleanupAzPSAccounts, setUserAgent } from './common/Utils';
33
import { AzPSLogin } from './PowerShell/AzPSLogin';
44
import { LoginConfig } from './common/LoginConfig';
55
import { AzureCliLogin } from './Cli/AzureCliLogin';
66

77
async function main() {
88
try {
99
setUserAgent();
10+
const preCleanup: string = process.env.AZURE_LOGIN_PRE_CLEANUP;
11+
if ('true' == preCleanup) {
12+
await cleanupAzCLIAccounts();
13+
if (core.getInput('enable-AzPSSession').toLowerCase() === "true") {
14+
await cleanupAzPSAccounts();
15+
}
16+
}
1017

1118
// prepare the login configuration
1219
var loginConfig = new LoginConfig();

0 commit comments

Comments
 (0)