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

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

  •  
  •   justincnn · 294 天前 · 717 次点击
    这是一个创建于 294 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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