更新 .github/workflows/buidl_and_push_ghcr.yml
Some checks failed
Docker Image CI / build (push) Failing after 12s
Some checks failed
Docker Image CI / build (push) Failing after 12s
This commit is contained in:
30
.github/workflows/buidl_and_push_ghcr.yml
vendored
30
.github/workflows/buidl_and_push_ghcr.yml
vendored
@@ -8,11 +8,9 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest # 确保你的 Gitea Runner 注册了这个标签
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# 【关键配置】在 K8s 中使用 DinD 的标准方式
|
||||
# 如果你的 runner 已经配置了挂载宿主机 docker sock,可以去掉 services 部分
|
||||
# 但对于纯 DinD 模式,建议保留以下配置
|
||||
# 声明 DinD 服务
|
||||
services:
|
||||
docker:
|
||||
image: docker:dind
|
||||
@@ -20,50 +18,36 @@ jobs:
|
||||
ports:
|
||||
- 2375:2375
|
||||
|
||||
# Gitea Actions 默认容器可能没有 git 或 docker 客户端
|
||||
# 指定一个包含常用工具的容器镜像作为执行环境
|
||||
container:
|
||||
image: catthehacker/ubuntu:act-latest
|
||||
# 告诉容器 Docker 守护进程在哪里 (对应上面的 service)
|
||||
env:
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
# 【修改点 1】在 K8s Pod 中,sidecar 容器即 localhost
|
||||
DOCKER_HOST: tcp://localhost:2375
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# 设置 Docker Buildx (兼容性最好)
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
# 显式指定 endpoint,防止找不到 docker 进程
|
||||
# 【修改点 2】显式指定 endpoint 为 localhost
|
||||
driver-opts: image=moby/buildkit:master
|
||||
endpoint: tcp://docker:2375
|
||||
endpoint: tcp://localhost:2375
|
||||
|
||||
# 登录 Gitea 内置的容器镜像仓库
|
||||
- name: Log in to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ gitea.server_url }} # 自动获取你的 Gitea 地址 (带协议)
|
||||
# 注意:login action通常只需要域名,如果 server_url 带 http/https 可能需要处理
|
||||
# 建议直接写域名,或者使用下面的这种方式:
|
||||
# registry: git.yourdomain.com
|
||||
registry: ${{ gitea.server_url }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
# 构建并推送
|
||||
# 建议使用官方 Action 替代 shell 脚本,因为它能自动处理 Buildx 上下文
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
push: true
|
||||
# 自动生成 tag
|
||||
tags: |
|
||||
${{ gitea.server_url }}/${{ gitea.actor }}/my-docs:latest
|
||||
${{ gitea.server_url }}/${{ gitea.actor }}/my-docs:${{ gitea.sha }}
|
||||
|
||||
# 如果上面 server_url 带了 http:// 前缀导致报错,请手动写死域名,例如:
|
||||
# tags: |
|
||||
# git.example.com/zeroornull/my-docs:latest
|
||||
Reference in New Issue
Block a user