mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-14 00:26:44 +00:00
added network prune
This commit is contained in:
@@ -171,6 +171,17 @@ export async function containerNetworkRemove(network: string): Promise<void> {
|
||||
await runDockerCommand(dockerArgs)
|
||||
}
|
||||
|
||||
export async function containerNetworkPrune(): Promise<void> {
|
||||
const dockerArgs = [
|
||||
'network',
|
||||
'prune',
|
||||
'--filter',
|
||||
`label=${getRunnerLabel()}`
|
||||
]
|
||||
|
||||
await runDockerCommand(dockerArgs)
|
||||
}
|
||||
|
||||
export async function containerPrune(): Promise<void> {
|
||||
const dockerPSArgs: string[] = [
|
||||
'ps',
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
import {
|
||||
containerRemove,
|
||||
containerNetworkRemove
|
||||
containerNetworkPrune,
|
||||
containerPrune
|
||||
} from '../dockerCommands/container'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export async function cleanupJob(args, state, responseFile): Promise<void> {
|
||||
const containerIds: string[] = []
|
||||
if (state?.container) {
|
||||
containerIds.push(state.container)
|
||||
}
|
||||
if (state?.services) {
|
||||
containerIds.push(state.services)
|
||||
}
|
||||
if (containerIds.length > 0) {
|
||||
await containerRemove(containerIds)
|
||||
}
|
||||
if (state.network) {
|
||||
await containerNetworkRemove(state.network)
|
||||
}
|
||||
export async function cleanupJob(): Promise<void> {
|
||||
await containerPrune()
|
||||
await containerNetworkPrune()
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ async function run(): Promise<void> {
|
||||
await prepareJob(args as PrepareJobArgs, responseFile)
|
||||
return exit(0)
|
||||
case Command.CleanupJob:
|
||||
await cleanupJob(null, state, null)
|
||||
await cleanupJob()
|
||||
return exit(0)
|
||||
case Command.RunScriptStep:
|
||||
await runScriptStep(args as RunScriptStepArgs, state)
|
||||
|
||||
Reference in New Issue
Block a user