mirror of
https://github.com/setube/ogame-vue-ts.git
synced 2026-05-12 16:05:12 +08:00
chore(ci): 优化 Docker 登录和镜像标签逻辑
- 调整 GHCR 登录注释,明确其始终执行 - 修改 Docker Hub 登录条件,仅检查 vars.DOCKERHUB_USERNAME 是否存在 - 更新 Docker Hub 镜像标签格式,添加 docker.io 前缀以确保唯一性 - 移除关于 GITHUB_TOKEN 的注释冗余内容 - 统一镜像推送逻辑中的标签生成方式
This commit is contained in:
12
.github/workflows/ogame-vue-ts.yml
vendored
12
.github/workflows/ogame-vue-ts.yml
vendored
@@ -27,17 +27,17 @@ jobs:
|
|||||||
- name: 设置 Docker Buildx
|
- name: 设置 Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
# 登录 GHCR
|
# 登录 GHCR(始终执行)
|
||||||
- name: 登录 GitHub Container Registry
|
- name: 登录 GitHub Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }} # 强烈建议直接用 GITHUB_TOKEN,不需要手动建 GHCR_TOKEN!
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
# 登录 Docker Hub(如果你还要推)
|
# 登录 Docker Hub(只在用户名存在时执行)
|
||||||
- name: 登录 Docker Hub
|
- name: 登录 Docker Hub
|
||||||
if: vars.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != ''
|
if: vars.DOCKERHUB_USERNAME != '' # 只检查 vars,忽略 secrets
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||||
@@ -53,7 +53,7 @@ jobs:
|
|||||||
tags: |
|
tags: |
|
||||||
ghcr.io/${{ github.repository_owner }}/ogame-vue-ts:latest
|
ghcr.io/${{ github.repository_owner }}/ogame-vue-ts:latest
|
||||||
ghcr.io/${{ github.repository_owner }}/ogame-vue-ts:${{ github.sha }}
|
ghcr.io/${{ github.repository_owner }}/ogame-vue-ts:${{ github.sha }}
|
||||||
${{ vars.DOCKERHUB_USERNAME != '' && format('{0}/ogame-vue-ts:latest', vars.DOCKERHUB_USERNAME) || '' }}
|
${{ vars.DOCKERHUB_USERNAME != '' && format('docker.io/{0}/ogame-vue-ts:latest', vars.DOCKERHUB_USERNAME) || '' }}
|
||||||
${{ vars.DOCKERHUB_USERNAME != '' && format('{0}/ogame-vue-ts:{1}', vars.DOCKERHUB_USERNAME, github.sha) || '' }}
|
${{ vars.DOCKERHUB_USERNAME != '' && format('docker.io/{0}/ogame-vue-ts:{1}', vars.DOCKERHUB_USERNAME, github.sha) || '' }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
Reference in New Issue
Block a user