1
0
Fork 0
mirror of https://github.com/docker/build-push-action.git synced 2025-05-07 14:09:30 +02:00

src: only log fatal errors in tailscale teardown

This commit is contained in:
Aditya Maru 2025-03-03 22:16:31 -05:00
parent 1def72df18
commit feb3751245
5 changed files with 26 additions and 16 deletions

View file

@ -195,15 +195,25 @@ export async function joinTailnet(): Promise<void> {
export async function leaveTailnet(): Promise<void> {
try {
// Check if we're part of a tailnet before trying to leave
const {stdout} = await execAsync('sudo tailscale status');
if (stdout.trim() !== '') {
await execAsync('sudo tailscale down');
core.debug('Successfully left tailnet');
} else {
core.debug('Not part of a tailnet, skipping leave');
try {
const {stdout} = await execAsync('sudo tailscale status');
if (stdout.trim() !== '') {
await execAsync('sudo tailscale down');
core.debug('Successfully left tailnet.');
} else {
core.debug('Not part of a tailnet, skipping leave.');
}
} catch (error: unknown) {
// Type guard for ExecException which has the code property
if (error && typeof error === 'object' && 'code' in error && error.code === 1) {
core.debug('Not part of a tailnet, skipping leave.');
return;
}
// Any other exit code indicates a real error
throw error;
}
} catch (error) {
core.warning(`Error leaving tailnet: ${error.message}`);
core.warning(`Error leaving tailnet: ${error instanceof Error ? error.message : String(error)}`);
}
}