Skip to content

Commit

Permalink
Merge pull request #97 from github/jurre/cleanup-volumes
Browse files Browse the repository at this point in the history
Cleanup docker volumes after running updater
  • Loading branch information
Jurre authored and GitHub committed Sep 29, 2021
2 parents 62b270b + 02791b6 commit 60c7b25
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/container-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const ContainerService = {
await container.start()
await container.wait()
} finally {
await container.remove()
await container.remove({v: true})
core.info(`Cleaned up container ${container.id}`)
}
}
Expand Down
19 changes: 17 additions & 2 deletions src/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ export class Updater {
// TODO: report job runner_error?
core.error(`Error ${e}`)
} finally {
await proxy.shutdown()
await this.docker.pruneNetworks()
await this.cleanup(proxy)
}
} catch (e) {
// TODO: report job runner_error?
Expand Down Expand Up @@ -165,4 +164,20 @@ export class Updater {
core.info(`Created ${updaterCommand} container: ${container.id}`)
return container
}

private async cleanup(proxy: Proxy): Promise<void> {
await proxy.shutdown()
await this.docker.pruneNetworks()

const outputDir = path.join(__dirname, '../output')
const repoDir = path.join(__dirname, '../repo')

if (fs.existsSync(outputDir)) {
fs.rmdirSync(outputDir, {recursive: true})
}

if (fs.existsSync(repoDir)) {
fs.rmdirSync(repoDir, {recursive: true})
}
}
}

0 comments on commit 60c7b25

Please sign in to comment.