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

Repository/image name should be lowercased automatically. #37

Closed
berkant opened this issue Apr 26, 2020 · 12 comments
Closed

Repository/image name should be lowercased automatically. #37

berkant opened this issue Apr 26, 2020 · 12 comments

Comments

@berkant
Copy link

berkant commented Apr 26, 2020

Name components may contain lowercase letters, digits and separators. A separator is defined as a period, one or two underscores, or one or more dashes. A name component may not start or end with a separator.
Src: https://docs.docker.com/engine/reference/commandline/tag/#extended-description.

I have no idea if the same rule applies to username or registry, but I have a failing build due to this. Note that repository name is feeded with ${{ github.repository }}/gateway. Currently, there is no toLower function in Actions.

2020-04-26T12:49:01.8839602Z ##[group]Run docker/build-push-action@v1
2020-04-26T12:49:01.8839748Z with:
2020-04-26T12:49:01.8839835Z   username: 0xbkt
2020-04-26T12:49:01.8840486Z   password: ***
2020-04-26T12:49:01.8840585Z   repository: 0xbkt/rEdAcTeD/gateway
2020-04-26T12:49:01.8840655Z   registry: docker.pkg.github.com
2020-04-26T12:49:01.8840739Z   tags: latest
2020-04-26T12:49:01.8840819Z   tag_with_ref: false
2020-04-26T12:49:01.8840902Z   tag_with_sha: false
2020-04-26T12:49:01.8840968Z   path: .
2020-04-26T12:49:01.8841048Z   always_pull: false
2020-04-26T12:49:01.8841130Z   add_git_labels: false
2020-04-26T12:49:01.8841225Z   push: true
2020-04-26T12:49:01.8841290Z ##[endgroup]
2020-04-26T12:49:01.8867757Z ##[command]/usr/bin/docker run --name dockergithubactionsv1_68dc5e --label c27d31 --workdir /github/workspace --rm -e INPUT_USERNAME -e INPUT_PASSWORD -e INPUT_REPOSITORY -e INPUT_REGISTRY -e INPUT_TAGS -e INPUT_TAG_WITH_REF -e INPUT_TAG_WITH_SHA -e INPUT_PATH -e INPUT_DOCKERFILE -e INPUT_TARGET -e INPUT_ALWAYS_PULL -e INPUT_BUILD_ARGS -e INPUT_CACHE_FROMS -e INPUT_LABELS -e INPUT_ADD_GIT_LABELS -e INPUT_PUSH -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/rEdAcTeD/rEdAcTeD":"/github/workspace" docker/github-actions:v1  "build-push"
2020-04-26T12:49:05.7322652Z Logging in to registry docker.pkg.github.com
2020-04-26T12:49:05.7555246Z WARNING! Using --password via the CLI is insecure. Use --password-stdin.
2020-04-26T12:49:05.8533235Z WARNING! Your password will be stored unencrypted in /github/home/.docker/config.json.
2020-04-26T12:49:05.8533483Z Login Succeeded
2020-04-26T12:49:05.8533831Z Configure a credential helper to remove this warning. See
2020-04-26T12:49:05.8534604Z https://docs.docker.com/engine/reference/commandline/login/#credentials-store
2020-04-26T12:49:05.8534726Z 
2020-04-26T12:49:05.8547653Z Building image [docker.pkg.github.com/0xbkt/rEdAcTeD/gateway:latest]
2020-04-26T12:49:05.8721089Z invalid argument "docker.pkg.github.com/0xbkt/rEdAcTeD/gateway:latest" for "-t, --tag" flag: invalid reference format: repository name must be lowercase
2020-04-26T12:49:05.8721637Z See 'docker build --help'.
2020-04-26T12:49:05.8734269Z Error: exit status 125
2020-04-26T12:49:05.8738409Z Usage:
2020-04-26T12:49:05.8738519Z exit status 125
2020-04-26T12:49:05.8739333Z   github-actions build-push [flags]
2020-04-26T12:49:05.8739585Z 
2020-04-26T12:49:05.8739769Z Flags:
2020-04-26T12:49:05.8740834Z   -h, --help   help for build-push
2020-04-26T12:49:05.8741420Z 
@berkant berkant changed the title Repository name should be lowercased. Repository/image name should be lowercased. Apr 26, 2020
@berkant berkant changed the title Repository/image name should be lowercased. Repository/image name should be lowercased automatically. May 4, 2020
@9ee1
Copy link

9ee1 commented Jun 28, 2020

For those interested in a workaround until/if this Action supports this out-of-the-box. I just added a preceding step to pipe ${{ github.repository }} to tr (that's a shell command if you're not familiar with it) to lowercase the repository name and then use ::set-env name (that's a workflow command if you're not familiar with it) to set an environment variable I can then reference in a successive docker/build-push-action@v1 step.

- id: read-docker-image-identifiers
  name: Read Docker Image Identifiers
  run: echo ::set-env name=IMAGE_REPOSITORY::$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')

- id: docker-build-push
  name: Docker Build and Push
  uses: docker/build-push-action@v1
  with:
    registry: docker.pkg.github.com
    repository: ${{ env.IMAGE_REPOSITORY }}/my-image
    username: ${{ github.actor }}
    password: ${{ github.token }}
    path: .
    dockerfile: ./build/Dockerfile

@crazy-max
Copy link
Member

Version 2 has been merged to the main branch and is therefore available via uses: docker/build-push-action@v2 (mutable tag).

As a reminder, this new version changes drastically and works with 3 new actions (login, setup-buildx and setup-qemu) that we have created. Many usage examples have been added to handle most use cases.

This new version should fix your issue. Don't hesitate if you have any questions.

@AnderssonPeter
Copy link

I'm somewhat confused i still get this error with v2, as i don't set any repository field I'm a bit confused what i need to change..

https://github.com/AnderssonPeter/test-actions/runs/1134569521?check_suite_focus=true
https://github.com/AnderssonPeter/test-actions/actions/runs/261363564/workflow

Also it would be nice if one of the examples in the readme was how to set it up with github packages.

@crazy-max
Copy link
Member

crazy-max commented Sep 18, 2020

Hi @AnderssonPeter,

I'm somewhat confused i still get this error with v2, as i don't set any repository field I'm a bit confused what i need to change..

This line in your workflow should reflect your repository name on DockerHub, not the one from GitHub actually.

Also it would be nice if one of the examples in the readme was how to set it up with github packages.

Yeah maybe we could add an example to use this action with the GitHub Container Registry. In the meantime you can take a look at this workflow. See also this section about usage of our login action.

@AnderssonPeter
Copy link

Thanks for the fast response, im trying to push to github instead of docker hub.
Ill try the link you provided.

@AnderssonPeter
Copy link

@crazy-max Thanks for you help, i managed to get it working, one thing it would be nice if the tool converted the repository name to lowercase, that way i could use ${{ github.repository_owner }} but as my github user has two capital chars in it that fails.

Again thank you for the fast help!

@berkant
Copy link
Author

berkant commented Sep 18, 2020

@AnderssonPeter Is it still not the case? I filed this issue to get this Action to already lowercase the name. I haven't tried the v2 yet though.

@0xERR0R
Copy link

0xERR0R commented Oct 23, 2020

No, it doesn't work. You can't use ${{ github.repository_owner }} in the tag name, if your github user name contains upper case letters (like my user).
Please fix it

@ccvca
Copy link

ccvca commented Nov 2, 2020

Warning: The set-env command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/

This is the "modern" version for setting env. (see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files )

    - name: PrepareReg Names
      run: |
        echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
        echo IMAGE_TAG=$(echo ${{ github.ref }} | tr '[:upper:]' '[:lower:]' | awk '{split($0,a,"/"); print a[3]}') >> $GITHUB_ENV

MarshalX added a commit to MarshalX/tgcalls that referenced this issue Feb 17, 2021
@JasonFreeberg
Copy link

This is the "modern" version for setting env. (see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#environment-files )

Man that's so ugly. I wish they would add a simple lowercase() function

L1ghtman2k added a commit to ScoreTrak/client that referenced this issue May 30, 2021
…g tags. Hence, we can cast the Image_Repository, and image tag to lower case as per: docker/build-push-action#37 (comment)
@noahjahn
Copy link

noahjahn commented Jul 8, 2021

The comment above says this was implemented with the v2 of the docker/build-push-action. This doesn't seem to be the case -- I still get an error when the username of the owner of the repository is not all lowercase.

@crazy-max
Copy link
Member

@noahjahn #237 (comment)

callumforrester added a commit to DiamondLightSource/hdf5-reader-service that referenced this issue Mar 14, 2022
callumforrester added a commit to DiamondLightSource/hdf5-reader-service that referenced this issue Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants