Skip to content

Commit 4c409a5

Browse files
committed
Remove temporary dependency directory in analyze post action
1 parent 251c7fd commit 4c409a5

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

lib/analyze-action-post.js

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action-post.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyze-action-post.ts

+17
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
* It will run after the all steps in this job, in reverse order in relation to
44
* other `post:` hooks.
55
*/
6+
import * as fs from "fs";
7+
68
import * as core from "@actions/core";
79

810
import * as actionsUtil from "./actions-util";
911
import { getGitHubVersion } from "./api-client";
1012
import { getCodeQL } from "./codeql";
1113
import { getConfig } from "./config-utils";
1214
import * as debugArtifacts from "./debug-artifacts";
15+
import { getJavaTempDependencyDir } from "./dependency-caching";
1316
import { EnvVar } from "./environment";
1417
import { getActionsLogger } from "./logging";
1518
import { checkGitHubVersionInRange, getErrorMessage } from "./util";
@@ -38,6 +41,20 @@ async function runWrapper() {
3841
);
3942
}
4043
}
44+
45+
// If we analysed Java in build-mode: none, we may have downloaded dependencies
46+
// to the temp directory. Clean these up so they don't persist unnecessarily
47+
// long on self-hosted runners.
48+
const javaTempDependencyDir = getJavaTempDependencyDir();
49+
if (fs.existsSync(javaTempDependencyDir)) {
50+
try {
51+
fs.rmSync(javaTempDependencyDir, { recursive: true });
52+
} catch (error) {
53+
logger.info(
54+
`Failed to remove temporary Java dependencies directory: ${getErrorMessage(error)}`,
55+
);
56+
}
57+
}
4158
} catch (error) {
4259
core.setFailed(
4360
`analyze post-action step failed: ${getErrorMessage(error)}`,

0 commit comments

Comments
 (0)