Also facing same issue my Github repo name contain capital letters but Docker require image name (repo) to be lowercase
Below solution worked for me
# add below lines where ever required
steps:
...
# repo name to lowercase
- name: Convert repo name to lowercase
id: lowercase
run: echo "repo_name_lc=${GITHUB_REPOSITORY##*/}" | tr '[:upper:]' '[:lower:]' >> $GITHUB_ENV
- name: Build and push
...
with:
...
tags: ${{ secrets.DOCKER_USERNAME }}/${{ env.repo_name_lc }}:latest
Explanation
${GITHUB_REPOSITORY##*/}
-> Contain full repo name ##*/
removes everything up to including the last /
.
tr '[:upper:]' '[:lower:]'
-> translates all uppercase to lowercase letter.
echo "repo_name_lc=..."
-> defining the variable
>> $GITHUB_ENV
-> appends the line to this file that GitHub Actions uses.