|
3 | 3 | * It will run after the all steps in this job, in reverse order in relation to
|
4 | 4 | * other `post:` hooks.
|
5 | 5 | */
|
| 6 | +import * as fs from "fs"; |
| 7 | + |
6 | 8 | import * as core from "@actions/core";
|
7 | 9 |
|
8 | 10 | import * as actionsUtil from "./actions-util";
|
9 | 11 | import { getGitHubVersion } from "./api-client";
|
10 | 12 | import { getCodeQL } from "./codeql";
|
11 | 13 | import { getConfig } from "./config-utils";
|
12 | 14 | import * as debugArtifacts from "./debug-artifacts";
|
| 15 | +import { getJavaTempDependencyDir } from "./dependency-caching"; |
13 | 16 | import { EnvVar } from "./environment";
|
14 | 17 | import { getActionsLogger } from "./logging";
|
15 | 18 | import { checkGitHubVersionInRange, getErrorMessage } from "./util";
|
@@ -38,6 +41,20 @@ async function runWrapper() {
|
38 | 41 | );
|
39 | 42 | }
|
40 | 43 | }
|
| 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 | + } |
41 | 58 | } catch (error) {
|
42 | 59 | core.setFailed(
|
43 | 60 | `analyze post-action step failed: ${getErrorMessage(error)}`,
|
|
0 commit comments