Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/custom envvar names #44

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

operatorequals
Copy link

This PR solves #42, enabling putting secrets under specific Environment Variable names. It does not work with Wildcard paths and throws an appropriate error about it.

@abhilash1in
Copy link
Owner

Thank you for the PR, @operatorequals! Will review it shortly.

@operatorequals
Copy link
Author

operatorequals commented Sep 19, 2022

Just added support for parse-json as I also needed it in my usecase.

With json secrets as:

{
  "key1":"value1",
  "key2":"value2"
}
      - name: Read secrets from AWS Secrets Manager into environment variables
        uses: operatorequals/aws-secrets-manager-action@feature/custom_envvar_names
        with:
          parse-json: true
          secrets: |
            json   | CUSTOM_ENV_VAR_JSON

populates CUSTOM_ENV_VAR_JSON_KEY1 and CUSTOM_ENV_VAR_JSON_KEY2

@operatorequals
Copy link
Author

Thank you for the PR, @operatorequals! Will review it shortly.

Hello @abhilash1in !
Added an extra feature here, can you please re-trigger the tests? I am currently using this code in my builds and it works properly!

@cwinters
Copy link

Is it possible for this to also support having no prefix as well? So in your example, if you had:

{
  "key1":"value1",
  "key2":"value2"
}

you'd get an environment with the values:

KEY1=value1
KEY2=value2

Apologies if this is already supported, I couldn't find any mention of it.

Thanks!

@cwinters
Copy link

...actually, scratch my request -- I found a one-liner to do this for me; this is in Ruby but I expect it'd be similarly short in other languages:

- name: Sync ENV to AWS secrets for branch
  run: |
     aws secretsmanager get-secret-value --secret-id ${{ inputs.aws_secret_name }} --query SecretString --output text | ruby script/secret_to_env.rb >> $GITHUB_ENV

where script/secret_to_env.rb is just the following (my keys are already uppercased and underscored):

require 'json'

JSON.parse($stdin.read).each { |k, v| puts "#{k}=#{v}" }

@operatorequals
Copy link
Author

operatorequals commented Sep 22, 2022

Is it possible for this to also support having no prefix as well? So in your example, if you had:

{
  "key1":"value1",
  "key2":"value2"
}

you'd get an environment with the values:

KEY1=value1
KEY2=value2

Apologies if this is already supported, I couldn't find any mention of it.

Thanks!

Best you could do right now is:

            json   | _

and get keys like _KEY1 and _KEY2.

Also a syntax like:

            json   | 

must do exactly what you want!

@adamwespiser
Copy link

@operatorequals just so I understand,

The syntax:

            json   | 

Would be able to import json secrets without a prefix? I believe that's what would happen form checking the code, but I'm not sure.

I'd like to use this plug in, but need to be able to import json secrets with no prefix.

@operatorequals
Copy link
Author

@operatorequals just so I understand,

The syntax:

            json   | 

Would be able to import json secrets without a prefix? I believe that's what would happen form checking the code, but I'm not sure.

I'd like to use this plug in, but need to be able to import json secrets with no prefix.

Try it! It should work as I explained!

@FannWuCircle
Copy link

@abhilash1in Is it good enough to merge back to master and bump a new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants