-
Notifications
You must be signed in to change notification settings - Fork 27
/
index.js
39 lines (30 loc) · 1.03 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
36
37
38
39
const core = require('@actions/core');
const fs = require('fs');
const path = require("path");
const fileName = core.getInput('name');
const jsonString = core.getInput('json');
const dir = core.getInput('dir');
const fullPath = path.join(process.env.GITHUB_WORKSPACE, dir || "", fileName);
let fileContent = JSON.stringify(jsonString);
fileContent = JSON.parse(fileContent)
try {
core.info('Creating json file...')
fs.writeFile(fullPath, fileContent, function (error) {
if (error) {
core.setFailed(error.message);
throw error
}
core.info('JSON file created.')
fs.readFile(fullPath, null, handleFile)
function handleFile(err, data) {
if (err) {
core.setFailed(error.message)
throw err
}
core.info('JSON checked.')
core.setOutput("successfully", `Successfully created json on ${fullPath} directory with ${fileContent} data`);
}
});
} catch (err) {
core.setFailed(err.message);
}