bug: only cleanup credentials if credentials were created (#96)
This commit is contained in:
parent
8c15757ad6
commit
443ae925ab
@ -193,8 +193,8 @@ regardless of the authentication mechanism.
|
|||||||
delegates.
|
delegates.
|
||||||
|
|
||||||
- `cleanup_credentials`: (Optional) If true, the action will remove any
|
- `cleanup_credentials`: (Optional) If true, the action will remove any
|
||||||
generated credentials from the filesystem upon completion. The default is
|
created credentials from the filesystem upon completion. This only applies
|
||||||
true.
|
if "create_credentials_file" is true. The default is true.
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
|
@ -73,8 +73,9 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
cleanup_credentials:
|
cleanup_credentials:
|
||||||
description: |-
|
description: |-
|
||||||
If true, the action will remove any generated credentials from the
|
If true, the action will remove any created credentials from the
|
||||||
filesystem upon completion.
|
filesystem upon completion. This only applies if "create_credentials_file"
|
||||||
|
is true.
|
||||||
default: true
|
default: true
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
|
11
dist/post/index.js
vendored
11
dist/post/index.js
vendored
@ -1587,8 +1587,14 @@ const actions_utils_1 = __nccwpck_require__(308);
|
|||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
const createCredentials = (0, core_1.getBooleanInput)('create_credentials_file');
|
||||||
|
if (!createCredentials) {
|
||||||
|
(0, core_1.info)(`Skipping credential cleanup - "create_credentials_file" is false.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const cleanupCredentials = (0, core_1.getBooleanInput)('cleanup_credentials');
|
const cleanupCredentials = (0, core_1.getBooleanInput)('cleanup_credentials');
|
||||||
if (!cleanupCredentials) {
|
if (!cleanupCredentials) {
|
||||||
|
(0, core_1.info)(`Skipping credential cleanup - "cleanup_credentials" is false.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Look up the credentials path, if one exists. Note that we only check the
|
// Look up the credentials path, if one exists. Note that we only check the
|
||||||
@ -1597,15 +1603,16 @@ function run() {
|
|||||||
// another environment variable manually.
|
// another environment variable manually.
|
||||||
const credentialsPath = process.env['GOOGLE_GHA_CREDS_PATH'];
|
const credentialsPath = process.env['GOOGLE_GHA_CREDS_PATH'];
|
||||||
if (!credentialsPath) {
|
if (!credentialsPath) {
|
||||||
|
(0, core_1.info)(`Skipping credential cleanup - $GOOGLE_GHA_CREDS_PATH is not set.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Remove the file.
|
// Remove the file.
|
||||||
const removed = yield (0, actions_utils_1.removeFile)(credentialsPath);
|
const removed = yield (0, actions_utils_1.removeFile)(credentialsPath);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
(0, core_1.info)(`Removed exported credentials at ${credentialsPath}`);
|
(0, core_1.info)(`Removed exported credentials at "${credentialsPath}".`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(0, core_1.info)('No exported credentials found');
|
(0, core_1.info)(`No exported credentials were found at "${credentialsPath}".`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
14
src/post.ts
14
src/post.ts
@ -8,8 +8,15 @@ import { errorMessage, removeFile } from '@google-github-actions/actions-utils';
|
|||||||
*/
|
*/
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const cleanupCredentials: boolean = getBooleanInput('cleanup_credentials');
|
const createCredentials = getBooleanInput('create_credentials_file');
|
||||||
|
if (!createCredentials) {
|
||||||
|
logInfo(`Skipping credential cleanup - "create_credentials_file" is false.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cleanupCredentials = getBooleanInput('cleanup_credentials');
|
||||||
if (!cleanupCredentials) {
|
if (!cleanupCredentials) {
|
||||||
|
logInfo(`Skipping credential cleanup - "cleanup_credentials" is false.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,15 +26,16 @@ export async function run(): Promise<void> {
|
|||||||
// another environment variable manually.
|
// another environment variable manually.
|
||||||
const credentialsPath = process.env['GOOGLE_GHA_CREDS_PATH'];
|
const credentialsPath = process.env['GOOGLE_GHA_CREDS_PATH'];
|
||||||
if (!credentialsPath) {
|
if (!credentialsPath) {
|
||||||
|
logInfo(`Skipping credential cleanup - $GOOGLE_GHA_CREDS_PATH is not set.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the file.
|
// Remove the file.
|
||||||
const removed = await removeFile(credentialsPath);
|
const removed = await removeFile(credentialsPath);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
logInfo(`Removed exported credentials at ${credentialsPath}`);
|
logInfo(`Removed exported credentials at "${credentialsPath}".`);
|
||||||
} else {
|
} else {
|
||||||
logInfo('No exported credentials found');
|
logInfo(`No exported credentials were found at "${credentialsPath}".`);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const msg = errorMessage(err);
|
const msg = errorMessage(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user