-
Notifications
You must be signed in to change notification settings - Fork 25
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
Retrieve values from GitHub Variables or Secrets #31
Comments
@mbraunwart-insight did you find a solution? |
I ended up writing a small script to set the environment variable vars as environment variables on the runner for consumption by replace-tokens. - run: |
import json
import os
env_file = os.getenv('GITHUB_ENV')
y = json.loads('''${{ inputs.vars }}''')
# y = json.loads('''${{ toJson(vars) }}''')
with open(env_file, "a") as file:
for key, value in y.items():
file.write(f"{key}={value}\n")
shell: python
- uses: cschleiden/replace-tokens@v1
with:
files: ${{ inputs.files }}
tokenPrefix: ${{ inputs.tokenPrefix }}
tokenSuffix: ${{ inputs.tokenSuffix }} When calling this small action I made (or you can make the update in the job reference itself) but This has worked for me so far! |
Excellent! I will try this. Thanks for quick response @mbraunwart-insight ! |
any way to merge toJson(vars) and toJson(secrets)? |
y = json.loads('''${{ toJson(vars) }}''') This was the fix for me! Thanks |
Unfortunately this is not an option for me as I cannot install python for use in GitHub Actions. So far as I'm aware, self-hosted runners can only setup python for github actions if they run Ubuntu, but I am running Amazon Linux 2023. If it's possible to transliterate this into bash, I could make it work. Though, I'm not as literate in that language for scripting. see issue: actions/setup-python#460 |
I was looking for hours for an action that could handle this. The qetza/replacetokens-action@v1 action can do this out of the box. I'd prefer not to have to write my own script for something the package should handle natively. Out of all the actions I tried, this is the only one I had success with.
Could something similar be used with this package? I tried the above syntax directly, but it didn't work. |
With the addition of GitHub Variables and the already existing secrets. Is there any limitation to accessing the API and retrieving the values for these parameters automatically without defining the parameters that need replaced? Similar to how the replace tokens extension works with variable groups in ADO?
Thanks!
The text was updated successfully, but these errors were encountered: