Additional function(s): lowercase|uppercase #25768
-
|
Noob GitHub Actions user here. My GitHub username includes uppercase characters. My first GitHub Actions workflow builds a container image to push to GitHub Container Registry. Container registries require lowercase repo names. I wanted to be able to: But this errors because I was unable to find a function nor any other way to pipe this value into Or, is there a better way to achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 21 comments 17 replies
-
|
The Or if you need the tag in a run step you could do the parameter expansion right there. |
Beta Was this translation helpful? Give feedback.
-
|
While using built-in shell functionality is probably more succinct, you could also use a string manipulation action if you want something that works the same regardless of the shell type: |
Beta Was this translation helpful? Give feedback.
-
|
How would you use it inside the run step, then? |
Beta Was this translation helpful? Give feedback.
-
|
When you write a variable definition to |
Beta Was this translation helpful? Give feedback.
-
|
The following commands can do this trick: In you case, it could be: |
Beta Was this translation helpful? Give feedback.
-
|
Python also does the exactly same thing: |
Beta Was this translation helpful? Give feedback.
-
|
IMHO: I am talking about those examples: I think those two links describe much more secure solutions:
You can also check out the security best practices for GitHub actions: https://res.cloudinary.com/da8kiytlc/image/upload/v1651737641/GitHub-Actions-Security-Best-Practices_cheatsheet.pdf |
Beta Was this translation helpful? Give feedback.
-
|
I don't like any answer above, for me, Github actions must have some built-in functions to do usual things like uppercase, camelcase, lowercase, etc.. |
Beta Was this translation helpful? Give feedback.
-
|
See this answer https://stackoverflow.com/a/63315136/416845 on how to use |
Beta Was this translation helpful? Give feedback.
-
|
These worked for me: - name: lowercase github.repository
run: |
echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV} - name: lowercase github.repository
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> ${GITHUB_ENV}then |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
None of these answers solve the actual problem. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
If i were to want to set a top-level environment variable, I have to be able to process that with the template system. There is no other option. Right now, it seems like this is impossible. |
Beta Was this translation helpful? Give feedback.
-
|
Today we wanted to use something like this: But I don't know if that's possible? Something for us to investigate. |
Beta Was this translation helpful? Give feedback.
-
|
To explicitly use it to extract the lower case name into Or likely more appropriately just use the |
Beta Was this translation helpful? Give feedback.
-
|
this is one of the saddest threads I've read regarding GitHub Actions ... |
Beta Was this translation helpful? Give feedback.
-
|
The fact that they don't have any upper/lowercase and they impose on us runner
I'm fighting for that. The first solution with bash substitution does not even work on macos that uses bash I need to learn python to have a multiple os run ? pfff what a joke |
Beta Was this translation helpful? Give feedback.
-
|
People adding AI to GitHub (fancy term to say UI over OpenAI/ChatGPT Tokens) would be seriously astonished if they learned how to code real things. But whatever green gremlins microshit has working over on GitHub clearly lack the skills to implement basic string manipulation in their pipelines for the container registry Maybe their Copilot garbage knows the answer? Oh wait... |
Beta Was this translation helpful? Give feedback.
-
|
I just had Copilot in a code review suggest a hallucination: |
Beta Was this translation helpful? Give feedback.
-
|
I originally came here for answers, but now I occasionally visit this thread for the lolz, because God forbid this easy problem ever gets fixed ... |
Beta Was this translation helpful? Give feedback.
The
envapproach is what I’d do, except that I’d use Bash parameter expansion to convert the case instead of hardcoding it:Or if you need the tag in a run step you could do the parameter expansion right there.