更新 .github/workflows/buidl_and_push_ghcr.yml
Some checks failed
Build and Push Docs / build-push (push) Failing after 2m42s
Some checks failed
Build and Push Docs / build-push (push) Failing after 2m42s
This commit is contained in:
98
.github/workflows/buidl_and_push_ghcr.yml
vendored
98
.github/workflows/buidl_and_push_ghcr.yml
vendored
@@ -1,62 +1,56 @@
|
||||
name: Build Docker Image
|
||||
name: Build and Push Docs
|
||||
run-name: Build Docs - ${{ gitea.actor }}
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
build-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Debug Docker environment
|
||||
run: |
|
||||
echo "=== Current user info ==="
|
||||
id
|
||||
echo ""
|
||||
echo "=== Environment variables ==="
|
||||
env | grep -i docker || echo "No DOCKER_ env vars"
|
||||
echo ""
|
||||
echo "=== Search for docker.sock ==="
|
||||
find / -name "docker.sock" 2>/dev/null || echo "Not found in filesystem"
|
||||
echo ""
|
||||
echo "=== Check common locations ==="
|
||||
ls -la /var/run/docker.sock 2>/dev/null || echo "/var/run/docker.sock not found"
|
||||
ls -la /run/docker.sock 2>/dev/null || echo "/run/docker.sock not found"
|
||||
ls -la ~/.docker/ 2>/dev/null || echo "~/.docker/ not found"
|
||||
echo ""
|
||||
echo "=== Check if docker command exists ==="
|
||||
which docker || echo "docker command not found"
|
||||
echo ""
|
||||
echo "=== Try docker version ==="
|
||||
docker version 2>&1 || echo "docker version failed"
|
||||
echo ""
|
||||
echo "=== Check mount points ==="
|
||||
mount | grep docker || echo "No docker mounts"
|
||||
|
||||
- name: Extract metadata
|
||||
# 1. 检出代码
|
||||
# 注意:必须包含 nginx/nginx.conf 和 Dockerfile
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# 2. 登录镜像仓库
|
||||
- name: Login to Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{ secrets.DOCKER_REGISTRY }}
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
# 3. 启用 Buildx
|
||||
# 这是必须的,因为 docker/build-push-action 依赖它
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
# 4. 生成 Metadata (自动生成 latest, v1.0.0 等标签)
|
||||
- name: Docker Metadata
|
||||
id: meta
|
||||
run: |
|
||||
echo "date=$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT
|
||||
echo "sha_short=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_OUTPUT
|
||||
|
||||
# 暂时注释掉构建步骤,等调试完成后再启用
|
||||
# - name: Build Docker image
|
||||
# run: |
|
||||
# docker build \
|
||||
# -t myapp:${{ steps.meta.outputs.sha_short }} \
|
||||
# -t myapp:latest \
|
||||
# -f Dockerfile \
|
||||
# .
|
||||
|
||||
# - name: List images
|
||||
# run: docker images | grep myapp
|
||||
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: Build and Push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
# 开启缓存,加速下一次构建(会缓存各层 Layer)
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
Reference in New Issue
Block a user