V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
justincnn
V2EX  ›  Docker

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

  •  
  •   justincnn · 2023-07-13 20:44:22 +08:00 · 842 次点击
    这是一个创建于 484 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    3 条回复    2023-07-14 15:15:26 +08:00
    paidaxtis
        1
    paidaxtis  
       2023-07-14 08:37:55 +08:00 via Android
    完整 yml 文件发一下,我似乎没碰到过
    justincnn
        2
    justincnn  
    OP
       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
        3
    paidaxtis  
       2023-07-14 15:15:26 +08:00
    @justincnn 看起来是你第一步登陆就报错了。有尝试过拆分你的 jobs 看一下具体哪一步出错吗?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1360 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:46 · PVG 01:46 · LAX 09:46 · JFK 12:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.