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? |
Replies: 22 comments 19 replies
|
The Or if you need the tag in a run step you could do the parameter expansion right there. |
|
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: |
|
How would you use it inside the run step, then? |
|
When you write a variable definition to |
|
The following commands can do this trick: In you case, it could be: |
|
Python also does the exactly same thing: |
|
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 |
|
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.. |
|
See this answer https://stackoverflow.com/a/63315136/416845 on how to use |
|
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 |
|
See also https://github.com/orgs/community/discussions/10553 |
|
None of these answers solve the actual problem. |
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. |
|
Today we wanted to use something like this: But I don't know if that's possible? Something for us to investigate. |
|
To explicitly use it to extract the lower case name into Or likely more appropriately just use the |
|
this is one of the saddest threads I've read regarding GitHub Actions ... |
|
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 |
|
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... |
|
I just had Copilot in a code review suggest a hallucination: |
|
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 ... |
|
I changed my username to be all lowercase because of this 6 year old issue |
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.