move pre cleanup to main and add pre-if and post-if (#484)

This commit is contained in:
Yan Xu
2024-09-14 13:28:11 +08:00
committed by GitHub
parent ffd504ae12
commit 73ceb51d05
2 changed files with 9 additions and 2 deletions

View File

@@ -39,6 +39,6 @@ branding:
color: 'blue'
runs:
using: 'node20'
pre: 'lib/cleanup/index.js'
main: 'lib/main/index.js'
post-if: (!env.AZURE_LOGIN_POST_CLEANUP || env.AZURE_LOGIN_POST_CLEANUP != 'false')
post: 'lib/cleanup/index.js'

View File

@@ -1,5 +1,5 @@
import * as core from '@actions/core';
import { setUserAgent } from './common/Utils';
import { cleanupAzCLIAccounts, cleanupAzPSAccounts, setUserAgent } from './common/Utils';
import { AzPSLogin } from './PowerShell/AzPSLogin';
import { LoginConfig } from './common/LoginConfig';
import { AzureCliLogin } from './Cli/AzureCliLogin';
@@ -7,6 +7,13 @@ import { AzureCliLogin } from './Cli/AzureCliLogin';
async function main() {
try {
setUserAgent();
const preCleanup: string = process.env.AZURE_LOGIN_PRE_CLEANUP;
if ('true' == preCleanup) {
await cleanupAzCLIAccounts();
if (core.getInput('enable-AzPSSession').toLowerCase() === "true") {
await cleanupAzPSAccounts();
}
}
// prepare the login configuration
var loginConfig = new LoginConfig();