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: 14 comments 7 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.
-
See also https://github.com/orgs/community/discussions/10553 |
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.
The
env
approach 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.