Giter Club home page Giter Club logo

base64-to-file's Introduction

Base64 to File

All Contributors

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.

Usage

- name: Run Workflow
  id: write_file
  uses: timheuer/[email protected]
  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/[email protected]
  with:
    fileName: 'myTemporaryFile.txt'
    encodedString: ${{ secrets.SOME_ENCODED_STRING }}

- name: Some other step
  uses: actions/someaction@master
  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

npm run package

which will modify/create the /dist folder with the final index.js output

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Michał Filipek
Michał Filipek

📖
Tim Heuer
Tim Heuer

💻 📖
tubone(Yu Otsubo)
tubone(Yu Otsubo)

💻
GG
GG

📖
Daniel Zarins
Daniel Zarins

🐛
Robbie Frodsham
Robbie Frodsham

🐛
Basti
Basti

🐛 💻
Codemenschen Android
Codemenschen Android

🐛
Osmund Maheswaran
Osmund Maheswaran

🐛
Rui Chen
Rui Chen

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

base64-to-file's People

Contributors

allcontributors[bot] avatar blarkdackbyte avatar chenrui333 avatar dependabot[bot] avatar filipkowicz avatar ninovanhooff avatar ontokrat avatar timheuer avatar tubone24 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

base64-to-file's Issues

Cant write file in sub directory

      - name: Write json in sub dir
        id: write_google_services_json
        uses: timheuer/[email protected]
        with:
          fileName: "./native/App_Resources/Android/google-services.json"
          encodedString: ${{ secrets.GOOGLE_SERVICES_JSON }}

When I try do this I get this error

/home/runner/work/_actions/timheuer/base64-to-file/v1.0.3/dist/index.js:75
      if (err) throw err;
               ^

[Error: ENOENT: no such file or directory, open '/home/runner/work/_te***/home/runner/work/front/front/native/App_Resources/Android/google-services.json'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/runner/work/_te***/home/runner/work/front/front/native/App_Resources/Android/google-services.json'
}

I need a intermediary step to move the file to right path now as my workaround, but would be nice to write a file to destination

Upgrade to Node 16

Everywhere this action is used, this warning is now showing:
[build] Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: timheuer/base64-to-file

Add more logging

Since writing this, I've realized the logging sucks. Needs more logging on different conditions:

  • If about to write 0 bytes, just fail sooner before trying to write
  • write out full path to temp file being written to
  • more error condition logging in core. Debug outputs
  • remove full env dump

File system error goes uncatched

Hi,
I just stumbled across this nice action and had a look at the code.
I noticed that filesystem errors will bubble up to the caller of the action. (Not sure how github actions handles that.) But the try catch block is effectively useless to catch fs errors. (catches Buffer errors, though)

I suggest to use the synchronous way of the node fs api. Or wrap the fs.writeFile call in a promise that we can await on as the run function is marked async.

So in short: Fs errors will not reach the catch block, so core.setFailed won't be called. Maybe the github actions runner will do the same automatically when the action throws, but I am not sure.

Automatically delete decrypted files

It would be nice if there was a post action to delete decrypted files.
Typically they store very secret information and while we should trust that the runner will discard of the data after the run is complete, it would be nice to have assurance that this is actually done.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.