How to pass a github secret to a shell script that is called by the script module ? #78
Replies: 2 comments 4 replies
-
|
First, you need to know that anything you save in your image will be publicly available if you're publishing on GHCR, so your assets could be picked up by anyone with access to the image. DO NOT store any secrets like passwords or tokens in any files inside your image. That being said, if you need to use some credentials during a module execution like a script, you can make use of the |
Beta Was this translation helpful? Give feedback.
-
|
I'm doing something wrong here because I can't get it to work. Let's say that everything works perfectly if I do NOT protect my curl'd assets behind apache auth. curl does its thing, my script works, the build succeeds. Huzzah. I then protect my assets with a username:password combination. This works as expected on the command line if I manually try "curl -u ${CREDS} --fail -L ". So I know that the curl portion works when supplied with an ENV variable in a local script or cli. So here's where it fails. I have created a Github "Environment" for my repo. Let's call the Environment "MAGIC_CURL_STUFF". This Environment has an "Environment Secret" defined. Let's call the secret "SUPER_SECRET_PASSWORD". This secret is simply a "username:password" string. My recipe.yml uses a from-file format. This works just great without the curl credentials part. Based on the example given in a previous comment, from-file yaml looks like so: Here is the relevant portion of curl_stuff.sh: But it falls apart in the build because curl still gets a null SUPER_SECRET_PASSWORD. Here is a snippet from the build log: I'm at a loss. Questions:
Sorry for the lengthy reply. My ignorance regarding both Github secrets and the blue-build process is creating a slew of failed builds. And now I'm obsessed with getting this to work. :-) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Sorry if this is explained elsewhere but I can't figure it out.
During the build process, I want to download some protected assets from a webserver, and this command needs to be in a script referenced by the script module in my recipe file. The curl command should look something like this:
curl -s -L -u "$CURL_CREDS" "${base_url}/${FILE}" | tar -xvzf - -C /usr/share/
Basically, this works fine right now without the "-u" option; e.g. from a website with unprotected files. I would like to put these assets behind apache auth, at least. However I cannot figure out how to add a GitHub secret (containing username:password info) and make this visible to my shell script as an ENV variable. (Or, realistically, whatever method works, env variable or otherwise.)
Here is the pipeline in a rough outline:
I would like to change the curl command to use a github secret with my username/password.
Is this possible?
Here is the relevant code from my build.yml file:
Let me know how to achieve this. Thank you !
Beta Was this translation helpful? Give feedback.
All reactions