Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get all GitHub secrets into env variables for Actions to access (powershell in my case)?

I read some similar posts but none seem to answer this question. I can set individual GitHub secrets into environment variables in an Action if I know the name of the secret:

env:
    PW_ID0007: "${{secrets.PW_ID0007}}"

How can I expose all secrets as environment variables without knowing their names (either in bulk or some way to iterate through them and set them individually?)

like image 765
mm_sml Avatar asked Sep 13 '25 16:09

mm_sml


1 Answers

There is a way to do that. Please check here

- name: view the secrets context
  shell: bash
  run: echo "$SECRETS_CONTEXT"
  env:
    SECRETS_CONTEXT: ${{ toJson(secrets) }}

In that way you will expose all secrets without knowing names:

enter image description here

And know what you need is go through this json using for instance jq and set them as env variable suing following syntax:

 echo "variable_name=variable_value" >> $GITHUB_ENV
like image 114
Krzysztof Madej Avatar answered Sep 15 '25 07:09

Krzysztof Madej