Skip to content

Commit 5516ead

Browse files
committed
add condition parameter to input file params
1 parent 6506324 commit 5516ead

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,21 @@ else {
4343

4444
// Read the files
4545
core.info("Reading files...");
46-
const files = await Promise.all(inputs.files.split("\n").map(async f => {
46+
const files = (await Promise.all(inputs.files.split("\n").map(async f => {
4747
const {path: filePath, params} = parseInputFileParams(f);
48+
if ("if" in params) {
49+
if (params.if === "false")
50+
return null;
51+
else if (params.if !== "false")
52+
core.warning(`Invalid condition value ‘${params.if}’. Must be ‘true’ or ‘false’.`);
53+
}
4854
const mimeType = params["type"] ?? "application/octet-stream";
4955
const fileName = params["filename"] ?? path.basename(filePath);
5056

5157
const data = await fs.readFile(filePath);
5258
core.info(`Read file: ${filePath} (type=${mimeType}; name=${fileName}; size=${data.length})`);
5359
return new File([data], path.basename(filePath), {type: mimeType});
54-
}));
60+
}))).filter(f => f !== null);
5561

5662
// Upload the files
5763
const octokit = github.getOctokit(GITHUB_TOKEN);

0 commit comments

Comments
 (0)