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 in cache parameters. #424

Closed
jbcpollak opened this issue Aug 2, 2021 · 2 comments · Fixed by #426
Closed

Repository/image name should be lowercased automatically in cache parameters. #424

jbcpollak opened this issue Aug 2, 2021 · 2 comments · Fixed by #426

Comments

@jbcpollak
Copy link

jbcpollak commented Aug 2, 2021

It appear the registry name is not lower-cased when used in the cache-from parameter. This appears related to #37, but not exactly the same.

Behaviour

Steps to reproduce this issue

  1. use ${{ github.repository}} in the cache-from parameter.

Expected behaviour

Would expect caching to work

Actual behaviour

The build output this while trying to restore the cache:

#10 importing cache manifest from ghcr.io/My-Org/repo:main
#10 ERROR: invalid reference format: repository name must be lowercase

Configuration

(This is an excerpt)

  env:
    REGISTRY: ghcr.io
    IMAGE_NAME: ${{ github.repository }}

....

      - name: Build and push dill to Docker
        uses: docker/build-push-action@v2
        with:
          context: .
          builder: ${{ steps.buildx.outputs.name }}
          file: ./docker/Dockerfile
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
          cache-to: type=inline,mode=max
@crazy-max
Copy link
Member

Like I said in #237 (comment), it adds an unnecessary complexity that should rather be handled upstream by GitHub.

Or you can add a step in your workflow:

    - name: Format repo slug
      uses: actions/github-script@v4
      id: repo_slug
      with:
        result-encoding: string
        script: return `ghcr.io/${github.repository.toLowerCase()}`

    - name: Build and push dill to Docker
      uses: docker/build-push-action@v2
      with:
        context: .
        builder: ${{ steps.buildx.outputs.name }}
        file: ./docker/Dockerfile
        push: true
        tags: ${{ steps.meta.outputs.tags }}
        labels: ${{ steps.meta.outputs.labels }}
        cache-from: type=registry,ref=${{ steps.repo_slug.outputs.result }}:main
        cache-to: type=inline

I will add a section in the troubleshooting notes.

As a side note, type=inline does not support mode=max. See https://github.com/moby/buildkit#export-cache.

@jbcpollak
Copy link
Author

Thanks for the documentation update, that will help

PromoFaux added a commit to PromoFaux/fintech-to-ynab that referenced this issue Oct 2, 2021
…ild-push-action#424 for reference of workaround

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
PromoFaux added a commit to PromoFaux/fintech-to-ynab that referenced this issue Oct 2, 2021
…ild-push-action#424 for reference of workaround

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
PromoFaux added a commit to PromoFaux/fintech-to-ynab that referenced this issue Oct 2, 2021
…ild-push-action#424 for reference of workaround

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
PromoFaux added a commit to PromoFaux/fintech-to-ynab that referenced this issue Oct 2, 2021
…ild-push-action#424 for reference of workaround

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
PromoFaux added a commit to PromoFaux/fintech-to-ynab that referenced this issue Oct 2, 2021
…ild-push-action#424 for reference of workaround

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants