我用 docker hub 来构建 github 的项目 docker ,每次只能第一次登录有效,这个请问如何处理?

2023-07-13 20:44:22 +08:00
 justincnn

具体如图,第一次 docker 镜像可以构建,第二次 docker hub 就直接提示登录错误:

870 次点击
所在节点    Docker
3 条回复
paidaxtis
2023-07-14 08:37:55 +08:00
完整 yml 文件发一下,我似乎没碰到过
justincnn
2023-07-14 10:24:45 +08:00
@paidaxtis

name: Docker build and push

on:
push:
branches:
- 'main'

env:
PLATFORMS: ${{ vars.PLATFORMS || 'linux/amd64' }}

jobs:
docker-build-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ github.actor }}/go-chatgpt-api
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max

- name: Log into ghcr
uses: docker/login-action@v2
if: ${{ vars.USE_GHCR == '1' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push to ghcr
uses: docker/build-push-action@v4
if: ${{ vars.USE_GHCR == '1' }}
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: ghcr.io/${{ github.actor }}/go-chatgpt-api
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
paidaxtis
2023-07-14 15:15:26 +08:00
@justincnn 看起来是你第一步登陆就报错了。有尝试过拆分你的 jobs 看一下具体哪一步出错吗?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/956573

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX