Skip to content

Update GitHub Action step "Check docker image" to accommodate for usernames with upper case characters #5503

@joshooaj

Description

@joshooaj

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:

  1. The value of github.event.repository.full_name is stored in an environment variable named REPO_FULL_NAME.
  2. The executions of docker run are updated to use ${REPO_FULL_NAME,,} in the image name instead of the raw value of github.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 }} build

Related 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions