Skip to content

Commit

Permalink
Merge branch 'tubone24-output_dir' into v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
timheuer committed Sep 1, 2021
2 parents 745dc3b + 4945e9e commit 83c4b96
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
description: 'Name of the file when written to temp location'
required: true
default: 'decoded-file.file'
fileDir:
description: 'If it is set, change the output location to specific one from temp location.'
required: false
encodedString:
description: 'The base64 encoded string'
required: true
Expand Down
15 changes: 10 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,26 +462,31 @@ const fse = __webpack_require__(226)
const path = __webpack_require__(622);

// get input parameter values from config
var fileName = path.join(process.env.RUNNER_TEMP,core.getInput('fileName'));
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 {
try {
console.log(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;
console.log('Wrote file!');
});

core.setOutput('filePath', fileName);
}
}
catch (error) {
core.setFailed(error.message);
}
Expand Down
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,31 @@ const fse = require('fs-extra')
const path = require('path');

// get input parameter values from config
var fileName = path.join(process.env.RUNNER_TEMP,core.getInput('fileName'));
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 {
try {
console.log(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;
console.log('Wrote file!');
});

core.setOutput('filePath', fileName);
}
}
catch (error) {
core.setFailed(error.message);
}
Expand Down

0 comments on commit 83c4b96

Please sign in to comment.