-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
35 lines (33 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const core = require("@actions/core");
const artifact = require("@actions/artifact");
const fs = require("fs");
async function run() {
try {
const name = core.getInput("name", { required: true });
const tempArtifactPath = fs.mkdtempSync("artifactExists-") + `/${name}`;
const artifactClient = artifact.create();
// download a single artifact
core.info(
`Starting download for ${name}. Temporary storing at ${tempArtifactPath} if exists.`
);
const downloadOptions = {
createArtifactFolder: false,
};
try {
const downloadResponse = await artifactClient.downloadArtifact(
name,
tempArtifactPath,
downloadOptions
);
core.info(`Artifact ${downloadResponse.artifactName} exists.`);
core.setOutput("exists", true);
} catch (err) {
core.info(`Artifact ${name} does not exist or is not available.`);
core.debug(err);
core.setOutput("exists", false);
}
} catch (err) {
core.setFailed(err.message);
}
}
run();