Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
joshooaj opened this issue May 10, 2023 · 1 comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@joshooaj
Copy link
Sponsor Contributor

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

joshooaj added a commit to joshooaj/mkdocs-material that referenced this issue May 10, 2023
This resolves an error on the "Check Docker image" build step for any forks under GitHub users with an upper case character in their GitHub username.
@squidfunk
Copy link
Owner

Thanks for suggesting. Sounds legit, I just merged the PR ☺️

@squidfunk squidfunk added bug Issue reports a bug resolved Issue is resolved, yet unreleased if open labels May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants