Docker 构建推送操作 "Not a valid object name";输出 repo 的所有分支和标签

Docker build-push-action "Not a valid object name"; outputs all branches and tags for repo

当 运行 我们的 docker 构建在 GitHub 操作工作流中时,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 build 命令的最后一部分有关:--push https://github.com/org/project.git#abc123,但这似乎不受我们任何配置的直接控制。

结果是 build-push-action runs in a "GitHub" context by default。至少,这意味着作为 pre-Dockerfile 命令的一部分拉下您的存储库。

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

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

由于我们之前作为结帐操作的一部分删除了存储库,因此它是多余的。