更新 .github/workflows/buidl_and_push_ghcr.yml
Some checks failed
Gitea Actions DinD Test / check-docker (push) Failing after 38s

This commit is contained in:
2025-12-18 14:11:06 +00:00
parent f7e8a7b3b3
commit 5fb8ec49a1

View File

@@ -1,56 +1,33 @@
name: Build and Push Docs name: Gitea Actions DinD Test
run-name: Build Docs - ${{ gitea.actor }}
on: on: [push]
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:
jobs: jobs:
build-push: check-docker:
# 确保这里的 labels 与你 runner 注册时的 labels 一致
# 默认通常是 ubuntu-latest, self-hosted 或者在 config 中定义的 labels
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
# 1. 检出代码 - name: Checkout code
# 注意:必须包含 nginx/nginx.conf 和 Dockerfile uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v3
# 2. 登录镜像仓库 - name: 1. 检查环境变量
- name: Login to Registry run: |
uses: docker/login-action@v2 echo "Checking DOCKER_HOST..."
with: echo "DOCKER_HOST is: $DOCKER_HOST"
registry: ${{ secrets.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# 3. 启用 Buildx - name: 2. 检查 Docker Daemon 连接
# 这是必须的,因为 docker/build-push-action 依赖它 run: |
- name: Set up Docker Buildx docker info
uses: docker/setup-buildx-action@v2
# 4. 生成 Metadata (自动生成 latest, v1.0.0 等标签) - name: 3. 测试运行容器 (Hello World)
- name: Docker Metadata run: |
id: meta docker run --rm alpine echo "Hello from DinD! Docker is working correctly."
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKER_REGISTRY }}/your-image-name
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha,format=short
# 5. 构建并推送 - name: 4. 测试构建镜像 (Optional)
- name: Build and Push run: |
uses: docker/build-push-action@v4 echo "FROM alpine" > Dockerfile
with: echo "RUN echo 'Built inside Gitea Actions'" >> Dockerfile
context: . docker build -t test-image:latest .
file: ./Dockerfile docker images | grep test-image
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# 开启缓存,加速下一次构建(会缓存各层 Layer
cache-from: type=gha
cache-to: type=gha,mode=max