Compare commits

..

No commits in common. "main" and "v.1.0.4" have entirely different histories.

10 changed files with 2751 additions and 11863 deletions

View file

@ -23,79 +23,6 @@
"code",
"doc"
]
},
{
"login": "tubone24",
"name": "tubone(Yu Otsubo)",
"avatar_url": "https://avatars.githubusercontent.com/u/9511227?v=4",
"profile": "https://portfolio.tubone-project24.xyz/",
"contributions": [
"code"
]
},
{
"login": "Ontokrat",
"name": "GG",
"avatar_url": "https://avatars.githubusercontent.com/u/23409319?v=4",
"profile": "https://github.com/Ontokrat",
"contributions": [
"doc"
]
},
{
"login": "danielz-nenda",
"name": "Daniel Zarins",
"avatar_url": "https://avatars.githubusercontent.com/u/74965667?v=4",
"profile": "http://www.nenda.com",
"contributions": [
"bug"
]
},
{
"login": "RobbieFrodsham",
"name": "Robbie Frodsham",
"avatar_url": "https://avatars.githubusercontent.com/u/47029725?v=4",
"profile": "https://github.com/RobbieFrodsham",
"contributions": [
"bug"
]
},
{
"login": "Blarkdackbyte",
"name": "Basti",
"avatar_url": "https://avatars.githubusercontent.com/u/14968844?v=4",
"profile": "https://github.com/Blarkdackbyte",
"contributions": [
"bug",
"code"
]
},
{
"login": "CodemenschenAndroid",
"name": "Codemenschen Android",
"avatar_url": "https://avatars.githubusercontent.com/u/60087122?v=4",
"profile": "https://github.com/CodemenschenAndroid",
"contributions": [
"bug"
]
},
{
"login": "awesomund",
"name": "Osmund Maheswaran",
"avatar_url": "https://avatars.githubusercontent.com/u/5211642?v=4",
"profile": "https://github.com/awesomund",
"contributions": [
"bug"
]
},
{
"login": "chenrui333",
"name": "Rui Chen",
"avatar_url": "https://avatars.githubusercontent.com/u/1580956?v=4",
"profile": "http://chenrui.dev",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
@ -103,7 +30,5 @@
"projectOwner": "timheuer",
"repoType": "github",
"repoHost": "https://github.com",
"skipCi": true,
"commitConvention": "angular",
"commitType": "docs"
"skipCi": true
}

View file

@ -1,22 +0,0 @@
{
"name": "Node.js & TypeScript",
"image": "mcr.microsoft.com/devcontainers/typescript-node:16-bullseye",
"features": {
"ghcr.io/devcontainers/features/sshd:1": {}
},
// Features to add to the dev container. More info: https://containers.dev/implementors/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install"
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

View file

@ -1,15 +1,11 @@
name: "Action Test"
on:
push:
branches:
- main
workflow_dispatch:
branches:
- main
push:
branches:
- master
jobs:
# test action works running from the graph
# test action works running from the graph
test:
runs-on: ${{ matrix.os }}
strategy:
@ -17,34 +13,18 @@ jobs:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Write file (1)
uses: actions/checkout@v1
- name: Run Workflow
id: write_file
uses: ./
with:
fileName: 'temp/dir/not/exists/myTemporaryFile.txt'
encodedString: ${{ secrets.SOME_ENCODED_STRING }} # SGVsbG8sIFdvcmxkIQ==
- name: Write file (2)
id: write_file2
uses: ./
with:
fileName: 'myTemporaryFile.json'
encodedString: ${{ secrets.ENCODED_JSON }}
- name: Echo file
run: |
echo ${{ steps.write_file.outputs.filePath }}
- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@master
with:
name: 'final-file-${{ matrix.os }}.txt'
path: ${{ steps.write_file.outputs.filePath }}
- name: Upload Artifact 2
uses: actions/upload-artifact@v3
with:
name: 'final-file-${{ matrix.os }}.json'
path: ${{ steps.write_file2.outputs.filePath }}
path: ${{ steps.write_file.outputs.filePath }}

1
.gitignore vendored
View file

@ -2,7 +2,6 @@ node_modules/
# Editors
.vscode
.vs/
# Logs
logs

View file

@ -1,6 +1,6 @@
# Base64 to File
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
Use this action if you need to get a file from a base64-encoded string that you may be storing in Secrets or elsewhere. This can be useful for certificate signing and storing the base64 cert in the Secrets.
@ -10,20 +10,19 @@ Use this action if you need to get a file from a base64-encoded string that you
```
- name: Run Workflow
id: write_file
uses: timheuer/base64-to-file@v1.2
uses: timheuer/base64-to-file@v1
with:
fileName: 'myTemporaryFile.txt'
fileDir: './main/folder/subfolder/'
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
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.
```
- name: Run Workflow
id: write_file
uses: timheuer/base64-to-file@v1.2
uses: timheuer/base64-to-file@v1
with:
fileName: 'myTemporaryFile.txt'
encodedString: ${{ secrets.SOME_ENCODED_STRING }}
@ -33,10 +32,6 @@ The Action has an output variable named filePath that you can use as this file i
with:
filelocation: ${{ steps.write_file.outputs.filePath }}
```
### Using this in a reusable workflow
As a special note, when using reusable workflows, repository secrets do not naturally 'flow' through to the workflow. So if your `encodedString` value is a repository secret and you expect this to work when this action is used in a reusable workflow, you need to specify the `secrets: inherit` value in that situation and put that where you are reusing this workflow.
## Building this repo
After making modifications to the source index.js file, to properly package the change you need to run
@ -54,27 +49,14 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/filipkowicz"><img src="https://avatars3.githubusercontent.com/u/4691550?v=4?s=100" width="100px;" alt="Michał Filipek"/><br /><sub><b>Michał Filipek</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/commits?author=filipkowicz" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://timheuer.com/blog/"><img src="https://avatars3.githubusercontent.com/u/4821?v=4?s=100" width="100px;" alt="Tim Heuer"/><br /><sub><b>Tim Heuer</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/commits?author=timheuer" title="Code">💻</a> <a href="https://github.com/timheuer/base64-to-file/commits?author=timheuer" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://portfolio.tubone-project24.xyz/"><img src="https://avatars.githubusercontent.com/u/9511227?v=4?s=100" width="100px;" alt="tubone(Yu Otsubo)"/><br /><sub><b>tubone(Yu Otsubo)</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/commits?author=tubone24" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Ontokrat"><img src="https://avatars.githubusercontent.com/u/23409319?v=4?s=100" width="100px;" alt="GG"/><br /><sub><b>GG</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/commits?author=Ontokrat" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://www.nenda.com"><img src="https://avatars.githubusercontent.com/u/74965667?v=4?s=100" width="100px;" alt="Daniel Zarins"/><br /><sub><b>Daniel Zarins</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/issues?q=author%3Adanielz-nenda" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/RobbieFrodsham"><img src="https://avatars.githubusercontent.com/u/47029725?v=4?s=100" width="100px;" alt="Robbie Frodsham"/><br /><sub><b>Robbie Frodsham</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/issues?q=author%3ARobbieFrodsham" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Blarkdackbyte"><img src="https://avatars.githubusercontent.com/u/14968844?v=4?s=100" width="100px;" alt="Basti"/><br /><sub><b>Basti</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/issues?q=author%3ABlarkdackbyte" title="Bug reports">🐛</a> <a href="https://github.com/timheuer/base64-to-file/commits?author=Blarkdackbyte" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/CodemenschenAndroid"><img src="https://avatars.githubusercontent.com/u/60087122?v=4?s=100" width="100px;" alt="Codemenschen Android"/><br /><sub><b>Codemenschen Android</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/issues?q=author%3ACodemenschenAndroid" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/awesomund"><img src="https://avatars.githubusercontent.com/u/5211642?v=4?s=100" width="100px;" alt="Osmund Maheswaran"/><br /><sub><b>Osmund Maheswaran</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/issues?q=author%3Aawesomund" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://chenrui.dev"><img src="https://avatars.githubusercontent.com/u/1580956?v=4?s=100" width="100px;" alt="Rui Chen"/><br /><sub><b>Rui Chen</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/commits?author=chenrui333" title="Code">💻</a></td>
</tr>
</tbody>
<tr>
<td align="center"><a href="https://timheuer.com/blog/"><img src="https://avatars3.githubusercontent.com/u/4821?v=4" width="100px;" alt=""/><br /><sub><b>Tim Heuer</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/commits?author=timheuer" title="Code">💻</a> <a href="https://github.com/timheuer/base64-to-file/commits?author=timheuer" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/filipkowicz"><img src="https://avatars3.githubusercontent.com/u/4691550?v=4" width="100px;" alt=""/><br /><sub><b>Michał Filipek</b></sub></a><br /><a href="https://github.com/timheuer/base64-to-file/commits?author=filipkowicz" title="Documentation">📖</a></td>
</tr>
</table>
<!-- markdownlint-restore -->
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

View file

@ -8,9 +8,6 @@ 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
@ -18,5 +15,5 @@ outputs:
filePath:
description: 'The temp file location'
runs:
using: 'node20'
using: 'node12'
main: 'dist/index.js'

7593
dist/index.js vendored

File diff suppressed because it is too large Load diff

View file

@ -3,31 +3,26 @@ 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 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);
try {
console.log(process.env);
const tempFile = Buffer.from(encodedString, 'base64');
if (tempFile.length == 0)
core.setFailed('encodedString value is not set');
core.setFailed('Temporary file value is not set');
fse.outputFile(fileName, tempFile, (err) => {
if (err) throw err;
core.debug('Wrote file!');
console.log('Wrote file!');
});
core.setOutput('filePath', fileName);
}
}
catch (error) {
core.setFailed(error.message);
}

6813
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "base64-to-file",
"version": "1.2.4",
"version": "1.0.0",
"description": "base64 encoded string to a file",
"main": "index.js",
"scripts": {
@ -25,12 +25,12 @@
},
"homepage": "https://github.com/timheuer/base64-to-file#readme",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/core": "^1.2.6",
"fs-extra": "^9.0.1"
},
"devDependencies": {
"@vercel/ncc": "^0.34.0",
"@zeit/ncc": "^0.20.5",
"eslint": "^6.3.0",
"jest": "^24.9.0"
}
}
}