1

In Github workflow, to get all the secrets using the below command and assigning it to a variable To get all the secrets from stored secrets assigned into a variable (based on key (name of the variable) value

      run: |
        for keyval in $(grep -E '": [^\{]'  <<< "$SECRETS_CONTEXT" | sed -e 's/: /=/' -e "s/\(\,\)$//"); do
          echo "export $keyval"
          eval export $keyval
        done  

Output export "var"=1 export "foo"="bar" export "x"="test"`

How can I export these variable as a global in Githubworkflow file. When I defined the steps it's not accessible from other steps.

steps:
    - name: Import value
      shell: bash
      run: |
        for keyval in $(grep -E '": [^\{]'  <<< "$SECRETS_CONTEXT" | sed -e 's/: /=/' -e "s/\(\,\)$//"); do
          echo "export $keyval"
          eval export $keyval
        done

Github secrets export in workflow

2
  • This will expose your secrets to all the repository users, which would be a huge security flaw. Isn't there another option to extract / get those values? Commented Nov 3, 2022 at 10:52
  • I believe not, as the secrets still are not decrypted, they will come like ***** . Please correct me if i am wrong Commented Nov 3, 2022 at 15:01

1 Answer 1

2

You need to set it to $GITHUB_ENV

echo secret=$(value) >> $GITHUB_ENV

And it will be available for the duration of the run. When you use export it is only set in that tiny scope.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.