docker build-push-action“不是有效的对象名称”;输出所有分支和标签的存储库

发布于 2025-01-24 18:00:33 字数 2272 浏览 4 评论 0原文

在GitHub Action Workflow中运行Docker构建时,Docker/build-Push-Action@V2继续在下面输出此错误。这是在运行Dockerfile中的任何命令之前:

Run docker/build-push-action@v2
  with:
    file: packages/api/Dockerfile
    tags: us.gcr.io/org-blahblah-shared/project-api:v7.9914
    push: true
    cache-from: type=gha
    cache-to: type=gha,mode=max
    load: false
    no-cache: false
    pull: false
    github-token: ***
  env:
    MAJOR_VERSION: v7
    DOCKER_REGISTRY: us.gcr.io
    GCP_PROJECT_ID: org-blahblah-shared
    TAG: v7.9914
Docker info
/usr/bin/docker buildx build --cache-from type=gha --cache-to type=gha,mode=max --file packages/api/Dockerfile --iidfile /tmp/docker-build-push-vytgyS/iidfile --secret id=GIT_AUTH_TOKEN,src=/tmp/docker-build-push-vytgyS/tmp-2350-NvWl1QbeU577 --tag us.gcr.io/org-blahblah-shared/project-api:v7.9914 --metadata-file /tmp/docker-build-push-vytgyS/metadata-file --push https://github.com/org/project.git#abc123
#1 [internal] load git source https://github.com/org/project.git#123abc
#1 0.176 hint: Using 'master' as the name for the initial branch. This default branch name
#1 0.176 hint: is subject to change. To configure the initial branch name to use in all
#1 0.176 hint: of your new repositories, which will suppress this warning, call:
#1 0.176 hint: 
#1 0.176 hint:  git config --global init.defaultBranch <name>
#1 0.176 hint: 
#1 0.176 hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
#1 0.176 hint: 'development'. The just-created branch can be renamed via this command:
#1 0.176 hint: 
#1 0.176 hint:  git branch -m <name>
#1 0.177 Initialized empty Git repository in /var/lib/buildkit/runc-overlayfs/snapshots/snapshots/1/fs/
#1 0.259 fatal: Not a valid object name 123abc^***commit***
#1 6.346 From https://github.com/org/project
#1 6.346  * [new branch]          blah
#1 6.346  * [new branch]          blah2
#1 6.347  * [new branch]          ...
#1 6.363  * [new tag]             v1
#1 6.363  * [new tag]             v2
#1 6.363  * [new tag]             ...

输出约3000行无用的输出,并且似乎是一些错误的配置。如何解决此根问题,或者至少可以控制输出?

它似乎与docker buildx buildx buildx命令的最后一部分有关:- push https://github.com/org/org/project.git#abc123,但是在我们的任何配置中,这似乎都不属于直接控制。

When running our docker build in a GitHub Action Workflow, the docker/build-push-action@v2 keeps outputting this error below. This is prior to running any of the commands in our Dockerfile:

Run docker/build-push-action@v2
  with:
    file: packages/api/Dockerfile
    tags: us.gcr.io/org-blahblah-shared/project-api:v7.9914
    push: true
    cache-from: type=gha
    cache-to: type=gha,mode=max
    load: false
    no-cache: false
    pull: false
    github-token: ***
  env:
    MAJOR_VERSION: v7
    DOCKER_REGISTRY: us.gcr.io
    GCP_PROJECT_ID: org-blahblah-shared
    TAG: v7.9914
Docker info
/usr/bin/docker buildx build --cache-from type=gha --cache-to type=gha,mode=max --file packages/api/Dockerfile --iidfile /tmp/docker-build-push-vytgyS/iidfile --secret id=GIT_AUTH_TOKEN,src=/tmp/docker-build-push-vytgyS/tmp-2350-NvWl1QbeU577 --tag us.gcr.io/org-blahblah-shared/project-api:v7.9914 --metadata-file /tmp/docker-build-push-vytgyS/metadata-file --push https://github.com/org/project.git#abc123
#1 [internal] load git source https://github.com/org/project.git#123abc
#1 0.176 hint: Using 'master' as the name for the initial branch. This default branch name
#1 0.176 hint: is subject to change. To configure the initial branch name to use in all
#1 0.176 hint: of your new repositories, which will suppress this warning, call:
#1 0.176 hint: 
#1 0.176 hint:  git config --global init.defaultBranch <name>
#1 0.176 hint: 
#1 0.176 hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
#1 0.176 hint: 'development'. The just-created branch can be renamed via this command:
#1 0.176 hint: 
#1 0.176 hint:  git branch -m <name>
#1 0.177 Initialized empty Git repository in /var/lib/buildkit/runc-overlayfs/snapshots/snapshots/1/fs/
#1 0.259 fatal: Not a valid object name 123abc^***commit***
#1 6.346 From https://github.com/org/project
#1 6.346  * [new branch]          blah
#1 6.346  * [new branch]          blah2
#1 6.347  * [new branch]          ...
#1 6.363  * [new tag]             v1
#1 6.363  * [new tag]             v2
#1 6.363  * [new tag]             ...

This outputs some 3000 lines of useless output, and appears to be some misconfiguration. How can I fix this root issue, or at least get the output under control?

It appears to be related to the last part of the docker buildx build command: --push https://github.com/org/project.git#abc123, but that does not seem to be within direct control in any of our configs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

困倦 2025-01-31 18:00:33

事实证明,build-push-action 在“ github”上下文中运行,默认情况下/a>。至少,这意味着将您的存储库作为dockerfile命令的一部分。

您可以通过使用以下方式将其更改为“文件”上下文:

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: user/app:latest

由于我们将存储库作为较早的结帐操作的一部分,因此是多余的。

Turns out the build-push-action runs in a "GitHub" context by default. At the very least, it means pulling down your repository as part of pre-Dockerfile command.

You can change it to the "file" context by using:

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: user/app:latest

Since we take down the repository as part of a checkout action earlier, it was redundant.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文