[skip ci] Merge pull request #25 from timheuer/v1.1.0
This commit is contained in:
@@ -15,7 +15,7 @@ Use this action if you need to get a file from a base64-encoded string that you
|
|||||||
fileName: 'myTemporaryFile.txt'
|
fileName: 'myTemporaryFile.txt'
|
||||||
encodedString: ${{ secrets.SOME_ENCODED_STRING }}
|
encodedString: ${{ secrets.SOME_ENCODED_STRING }}
|
||||||
```
|
```
|
||||||
|
By default this writes the `fileName` to a temporary path defined by `env.RUNNER_TEMP`. If you want a different path that is writable, specify `fileDir` as an input argument as well and then `fileDir` and `fileName` will be combined to create the path where the output will be written. This assumes permissions in the `fileDir` are correct and does not try to set them.
|
||||||
## Using the file in a later step
|
## Using the file in a later step
|
||||||
The Action has an output variable named filePath that you can use as this file is written to TEMP. Make sure you ad an `id` to your step when using this Action so that you can easily pull it out of the steps context later.
|
The Action has an output variable named filePath that you can use as this file is written to TEMP. Make sure you ad an `id` to your step when using this Action so that you can easily pull it out of the steps context later.
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ inputs:
|
|||||||
description: 'Name of the file when written to temp location'
|
description: 'Name of the file when written to temp location'
|
||||||
required: true
|
required: true
|
||||||
default: 'decoded-file.file'
|
default: 'decoded-file.file'
|
||||||
|
fileDir:
|
||||||
|
description: 'If it is set, change the output location to specific one from temp location.'
|
||||||
|
required: false
|
||||||
encodedString:
|
encodedString:
|
||||||
description: 'The base64 encoded string'
|
description: 'The base64 encoded string'
|
||||||
required: true
|
required: true
|
||||||
|
|||||||
15
dist/index.js
vendored
15
dist/index.js
vendored
@@ -462,26 +462,31 @@ const fse = __webpack_require__(226)
|
|||||||
const path = __webpack_require__(622);
|
const path = __webpack_require__(622);
|
||||||
|
|
||||||
// get input parameter values from config
|
// 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');
|
var encodedString = core.getInput('encodedString');
|
||||||
|
|
||||||
// most @actions toolkit packages have async methods
|
// most @actions toolkit packages have async methods
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
console.log(process.env);
|
console.log(process.env);
|
||||||
const tempFile = Buffer.from(encodedString, 'base64');
|
const tempFile = Buffer.from(encodedString, 'base64');
|
||||||
|
|
||||||
if (tempFile.length == 0)
|
if (tempFile.length == 0)
|
||||||
core.setFailed('Temporary file value is not set');
|
core.setFailed('Temporary file value is not set');
|
||||||
|
|
||||||
fse.outputFile(fileName, tempFile, (err) => {
|
fse.outputFile(fileName, tempFile, (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
console.log('Wrote file!');
|
console.log('Wrote file!');
|
||||||
});
|
});
|
||||||
|
|
||||||
core.setOutput('filePath', fileName);
|
core.setOutput('filePath', fileName);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|||||||
15
index.js
15
index.js
@@ -3,26 +3,31 @@ const fse = require('fs-extra')
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// get input parameter values from config
|
// 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');
|
var encodedString = core.getInput('encodedString');
|
||||||
|
|
||||||
// most @actions toolkit packages have async methods
|
// most @actions toolkit packages have async methods
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
console.log(process.env);
|
console.log(process.env);
|
||||||
const tempFile = Buffer.from(encodedString, 'base64');
|
const tempFile = Buffer.from(encodedString, 'base64');
|
||||||
|
|
||||||
if (tempFile.length == 0)
|
if (tempFile.length == 0)
|
||||||
core.setFailed('Temporary file value is not set');
|
core.setFailed('Temporary file value is not set');
|
||||||
|
|
||||||
fse.outputFile(fileName, tempFile, (err) => {
|
fse.outputFile(fileName, tempFile, (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
console.log('Wrote file!');
|
console.log('Wrote file!');
|
||||||
});
|
});
|
||||||
|
|
||||||
core.setOutput('filePath', fileName);
|
core.setOutput('filePath', fileName);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "base64-to-file",
|
"name": "base64-to-file",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "base64-to-file",
|
"name": "base64-to-file",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"description": "base64 encoded string to a file",
|
"description": "base64 encoded string to a file",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user