mirror of
https://github.com/timheuer/base64-to-file
synced 2025-06-30 16:52:52 +02:00
Compare commits
No commits in common. "main" and "v1.0.4" have entirely different histories.
10 changed files with 2751 additions and 11863 deletions
|
@ -23,79 +23,6 @@
|
||||||
"code",
|
"code",
|
||||||
"doc"
|
"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,
|
"contributorsPerLine": 7,
|
||||||
|
@ -103,7 +30,5 @@
|
||||||
"projectOwner": "timheuer",
|
"projectOwner": "timheuer",
|
||||||
"repoType": "github",
|
"repoType": "github",
|
||||||
"repoHost": "https://github.com",
|
"repoHost": "https://github.com",
|
||||||
"skipCi": true,
|
"skipCi": true
|
||||||
"commitConvention": "angular",
|
|
||||||
"commitType": "docs"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
|
||||||
}
|
|
36
.github/workflows/test-matrix.yml
vendored
36
.github/workflows/test-matrix.yml
vendored
|
@ -1,15 +1,11 @@
|
||||||
name: "Action Test"
|
name: "Action Test"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- master
|
||||||
workflow_dispatch:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# test action works running from the graph
|
# test action works running from the graph
|
||||||
test:
|
test:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -17,34 +13,18 @@ jobs:
|
||||||
os: [ubuntu-latest, windows-latest]
|
os: [ubuntu-latest, windows-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v1
|
||||||
|
- name: Run Workflow
|
||||||
- name: Write file (1)
|
|
||||||
id: write_file
|
id: write_file
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
fileName: 'temp/dir/not/exists/myTemporaryFile.txt'
|
fileName: 'temp/dir/not/exists/myTemporaryFile.txt'
|
||||||
encodedString: ${{ secrets.SOME_ENCODED_STRING }} # SGVsbG8sIFdvcmxkIQ==
|
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
|
- name: Echo file
|
||||||
run: |
|
run: |
|
||||||
echo ${{ steps.write_file.outputs.filePath }}
|
echo ${{ steps.write_file.outputs.filePath }}
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@master
|
||||||
with:
|
with:
|
||||||
name: 'final-file-${{ matrix.os }}.txt'
|
name: 'final-file-${{ matrix.os }}.txt'
|
||||||
path: ${{ steps.write_file.outputs.filePath }}
|
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 }}
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,7 +2,6 @@ node_modules/
|
||||||
|
|
||||||
# Editors
|
# Editors
|
||||||
.vscode
|
.vscode
|
||||||
.vs/
|
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
|
|
38
README.md
38
README.md
|
@ -1,6 +1,6 @@
|
||||||
# Base64 to File
|
# Base64 to File
|
||||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||||
[](#contributors-)
|
[](#contributors-)
|
||||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
<!-- 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.
|
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
|
- name: Run Workflow
|
||||||
id: write_file
|
id: write_file
|
||||||
uses: timheuer/base64-to-file@v1.2
|
uses: timheuer/base64-to-file@v1
|
||||||
with:
|
with:
|
||||||
fileName: 'myTemporaryFile.txt'
|
fileName: 'myTemporaryFile.txt'
|
||||||
fileDir: './main/folder/subfolder/'
|
|
||||||
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.
|
||||||
|
|
||||||
```
|
```
|
||||||
- name: Run Workflow
|
- name: Run Workflow
|
||||||
id: write_file
|
id: write_file
|
||||||
uses: timheuer/base64-to-file@v1.2
|
uses: timheuer/base64-to-file@v1
|
||||||
with:
|
with:
|
||||||
fileName: 'myTemporaryFile.txt'
|
fileName: 'myTemporaryFile.txt'
|
||||||
encodedString: ${{ secrets.SOME_ENCODED_STRING }}
|
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:
|
with:
|
||||||
filelocation: ${{ steps.write_file.outputs.filePath }}
|
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
|
## Building this repo
|
||||||
After making modifications to the source index.js file, to properly package the change you need to run
|
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 -->
|
<!-- prettier-ignore-start -->
|
||||||
<!-- markdownlint-disable -->
|
<!-- markdownlint-disable -->
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tr>
|
||||||
<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" 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"><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>
|
||||||
<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>
|
</tr>
|
||||||
<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>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<!-- markdownlint-restore -->
|
<!-- markdownlint-enable -->
|
||||||
<!-- prettier-ignore-end -->
|
<!-- prettier-ignore-end -->
|
||||||
|
|
||||||
<!-- ALL-CONTRIBUTORS-LIST: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!
|
|
@ -8,9 +8,6 @@ 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
|
||||||
|
@ -18,5 +15,5 @@ outputs:
|
||||||
filePath:
|
filePath:
|
||||||
description: 'The temp file location'
|
description: 'The temp file location'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
7593
dist/index.js
vendored
7593
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
21
index.js
21
index.js
|
@ -3,31 +3,26 @@ 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;
|
var fileName = path.join(process.env.RUNNER_TEMP,core.getInput('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 {
|
||||||
core.debug(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('encodedString 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;
|
||||||
core.debug('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);
|
||||||
}
|
}
|
||||||
|
|
6813
package-lock.json
generated
6813
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "base64-to-file",
|
"name": "base64-to-file",
|
||||||
"version": "1.2.4",
|
"version": "1.0.0",
|
||||||
"description": "base64 encoded string to a file",
|
"description": "base64 encoded string to a file",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -25,12 +25,12 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/timheuer/base64-to-file#readme",
|
"homepage": "https://github.com/timheuer/base64-to-file#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.2.6",
|
||||||
"fs-extra": "^9.0.1"
|
"fs-extra": "^9.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "^0.34.0",
|
"@zeit/ncc": "^0.20.5",
|
||||||
"eslint": "^6.3.0",
|
"eslint": "^6.3.0",
|
||||||
"jest": "^24.9.0"
|
"jest": "^24.9.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue