-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Update GitHub Action step "Check docker image" to accommodate for usernames with upper case characters #5503
Description
Context
We intend to keep our fork in sync, and automatically publish updated container images to our GHCR.
Description
Our organization username has upper case characters in it, and this causes the "Check docker image" build step to fail with the following error:
Run docker run --rm -i --user $(id -u):$(id -g) -e GH_TOKEN=${GH_TOKEN} -v ${PWD}:/docs ghcr.io/MilestoneSystemsInc/mkdocs-material-insiders:9.1.11-insiders-4.33.1 new .
docker: invalid reference format: repository name must be lowercase.
See 'docker run --help'.
Error: Process completed with exit code 125.
To resolve this for any user or organization with upper case characters in their GitHub name, I'm proposing to convert the value of github.event.repository.full_name to lower case before calling docker run when validating the docker image.
Note: This is being shared as a change request instead of a bug because the bug template requires an attached reproduction. I don't think it makes sense to follow the creating-a-reproduction guide for an issue related to GitHub Action workflow(s).
Proposed change
In the example below, the "Check Docker image" step has the following modifications:
- The value of
github.event.repository.full_nameis stored in an environment variable namedREPO_FULL_NAME. - The executions of
docker runare updated to use${REPO_FULL_NAME,,}in the image name instead of the raw value ofgithub.event.repository.full_name.
Note: The syntax ${VAR,,} is an example of parameter expansion in bash. In this case it converts all upper case characters to lowercase. The reverse could be done with ${VAR^^}.
- name: Check Docker image
working-directory: /tmp
env:
REPO_FULL_NAME: '${{ github.event.repository.full_name }}'
run: |
docker run --rm -i --user $(id -u):$(id -g) -e GH_TOKEN=${GH_TOKEN} -v ${PWD}:/docs ghcr.io/${REPO_FULL_NAME,,}:${{ steps.meta.outputs.version }} new .
docker run --rm -i --user $(id -u):$(id -g) -e GH_TOKEN=${GH_TOKEN} -v ${PWD}:/docs ghcr.io/${REPO_FULL_NAME,,}:${{ steps.meta.outputs.version }} buildRelated links
Use Cases
This change should not impact authors, users. It should only improve the CI/CD experience for anyone using GitHub Actions to publish updated container images to GHCR using the unaltered build.yml from squidfunk/mkdocs-material or squidfunk/mkdocs-material-insiders.
Visuals
No response
Before submitting
- I have read and followed the change request guidelines.
- I have verified that my idea is a change request and not a bug report.
- I have ensured that, to the best of my knowledge, my idea will benefit the entire community.
- I have included relevant links to the documentation, related issues, and discussions to underline the need for my idea.