forked from timheuer/base64-to-file
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (29 loc) · 936 Bytes
/
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
const core = require('@actions/core');
const fse = require('fs-extra')
const path = require('path');
// get input parameter values from config
var fileName;
if (core.getInput('fileDir', {required: false})) {
fileName = path.join(core.getInput('fileDir'), core.getInput('fileName', {required: false}));
} else {
fileName = path.join(process.env.RUNNER_TEMP,core.getInput('fileName'));
}
var encodedString = core.getInput('encodedString');
// most @actions toolkit packages have async methods
async function run() {
try {
core.debug(process.env);
const tempFile = Buffer.from(encodedString, 'base64');
if (tempFile.length == 0)
core.setFailed('Temporary file value is not set');
fse.outputFile(fileName, tempFile, (err) => {
if (err) throw err;
core.debug('Wrote file!');
});
core.setOutput('filePath', fileName);
}
catch (error) {
core.setFailed(error.message);
}
}
run()