Giter Club home page Giter Club logo

secret-parser's Introduction

Secret Parser Action

Replaces GitHub Actions secrets referenced in files with their raw values.

Inputs

filename

Required File where GitHub Actions Secrets references should be parsed and replaced.

secret-name

Required Name of secret to search for in the designated file.

secret-value

Required Value of secret to replace reference with in designated file.

Example usage

  1. Create a file in the repository which references GitHub actions secret. For example, test.json:
{
  "important_value" : "${{ secrets.important_value }}"
}
  1. Create a GitHub action secret with a key of: important_value

  2. Add the following to your workflow configuration file (parameters shown below are for this demonstration only):

uses: jwsi/secret-parser@v1
with:
  filename: test.json
  secret-name: important_value
  secret-value: ${{ secrets.important_value }}
  1. During workflow execution, test.json (or a file of one's choosing) will be parsed and the reference to a GitHub secret will be replaced with the corresponding secret value.

secret-parser's People

Contributors

jwsi 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

Watchers

 avatar  avatar

secret-parser's Issues

More detail about patterns

Hi and thanks for your github action.

This might sound basic, but I'm having trouble to making sure the action is working fine for me.
I believe it is doing the replacement, but since it breaks my build afterwards, I suspect it is maybe doing too much replacement.

And what's confusing is that your example in readme is using the same string for both the key in the JSON and the secret name.
When you put secret-name: important_value as an example, it's not clear to me to what it refers: it could be the json key or the name of the secret key.

In my case, it looks like this:

{
...
"private_key_id": "${{ secrets.GOOGLE_PRIVATE_KEY_ID }}"
...}

and of course the secret name is GOOGLE_PRIVATE_KEY_ID

My first intuition was to use the following config:

          secret-name: private_key_id
          secret-value: ${{ secrets.GOOGLE_PRIVATE_KEY_ID }}

Bad choice! It failed.
So I tried

          secret-name: GOOGLE_PRIVATE_KEY_ID
          secret-value: ${{ secrets.GOOGLE_PRIVATE_KEY_ID }}

Now the action works, but surprisingly I get a JSON parse error later in the process, which I suspect to be related even if there is a slight chance it's not:

SyntaxError: Unexpected token 
 in JSON at position 177
    at JSON.parse (<anonymous>)

Would you spot my mistake, and additional, would you consider rephrase the Readme to make it more explicit?
Or is it mandatory to use the same key name?

Thanks!

Assumes incorrect root path

Using this in May 2023 with ubuntu-latest fails with the following error message (redacted actual file names)

Attempting to parse file: /home/runner/work/my-project/my-project/kubernetes/config/secrets/my-secrets.yaml
Traceback (most recent call last):
  File "/main.py", line 25, in <module>
    parser(args.filename, args.secret_name, args.secret_value)
  File "/main.py", line 9, in parser
    with open('/github/workspace/' + filename, 'r') as fd:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/github/workspace//home/runner/work/my-project/my-project/kubernetes/config/secrets/my-secrets.yaml'

There is no /github/workspace/ directory in an ubuntu-latest runner.

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.