-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (20 loc) · 769 Bytes
/
index.js
File metadata and controls
26 lines (20 loc) · 769 Bytes
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
const core = require('@actions/core');
const fs = require('fs');
const fileName = core.getInput('file-name');
const inputPrefix = "INPUT_"; // This is the prefix used by GitHub Actions
const path = require("path");
const fullPath = path.join(process.env.GITHUB_WORKSPACE, fileName);
var obj = {};
Object.keys(process.env).forEach(function(key) {
if(key.startsWith(inputPrefix) && key != "INPUT_FILE-NAME") {
obj[key.substring(inputPrefix.length)] = process.env[key];
}
});
const fileContent = JSON.stringify(obj);
fs.writeFile(fullPath, fileContent, function (error) {
if (error) {
core.setFailed(error.message);
}
console.log(`Successfully written file ${fullPath} with content ${fileContent}`);
core.setOutput("full-path", fullPath);
});