ci: switch from gitea to github actions multi-arch build

This commit is contained in:
Antigravity committed 2026-09-19 14:12:17 +08:00
1 parent f364821128
commit 1291fd1381
4 files changed
+66 -61

No files matched your search

-57
View File
@@ -1,57 +0,0 @@
name: Build and Push Docker Image
on:
push:
branches:
- master
- main
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
run: |
git clone --depth=1 "https://${{ gitea.actor }}:${{ secrets.GITHUB_TOKEN }}@git.openlocalpdf.com/${{ gitea.repository }}.git" .
git checkout "${{ github.sha }}" || true
- name: Check Runner Environment
run: |
echo "=== System Info ==="
uname -a || true
which docker || echo "docker CLI not found!"
docker version || echo "docker daemon not accessible!"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Container Registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.openlocalpdf.com -u "${{ gitea.actor }}" --password-stdin
- name: Build and Push Docker image (Multi-Arch)
run: |
IMAGE_NAME="git.openlocalpdf.com/${{ gitea.repository }}"
TAGS="-t ${IMAGE_NAME}:latest"
# 如果是 tag 触发,则同时打上具体版本 tag
if [ "${{ github.ref_type }}" = "tag" ]; then
TAG_NAME="${{ github.ref_name }}"
echo "Tag detected: ${TAG_NAME}"
TAGS="${TAGS} -t ${IMAGE_NAME}:${TAG_NAME}"
fi
echo "Building and pushing multi-arch image: ${TAGS}"
docker buildx build \
--platform linux/amd64,linux/arm64 \
${TAGS} \
--push \
-f Dockerfile .
+61
View File
@@ -0,0 +1,61 @@
name: Build and Push Multi-Arch Docker Image
on:
push:
branches:
- master
- main
tags:
- 'v*'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/v') }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
+1
View File
@@ -3,3 +3,4 @@ Thumbs.db
*.log *.log
.codegraph/ .codegraph/
.omo/ .omo/
.idea/
+4 -4
View File
@@ -17,9 +17,9 @@
docker build -t webman:8.2 . docker build -t webman:8.2 .
``` ```
### Gitea CI/CD 自动构建 ### GitHub Actions 自动构建与发布
已配置 `.gitea/workflows/build.yaml`。每次推送到 `master` / `main` 或推送 tag(如 `v1.0.0`)时,Gitea Actions 会自动构建并推送到 Gitea 镜像仓库: 已配置 `.github/workflows/build.yml`。每次推送到 `master` / `main` 或推送 tag(如 `v1.0.0`)时,GitHub Actions 会自动通过 QEMU + Buildx 构建多架构镜像(`linux/amd64` 与 `linux/arm64`),并发布到 GitHub Container Registry (GHCR):
- **Registry**: `git.openlocalpdf.com:222/gitea/webman-docker:latest` - **Registry**: `ghcr.io/567ai/webman-docker:latest`(或对应 tag 如 `:v1.0.0`)
- 确保 Gitea 仓库已启用 Actions 且部署有对应 Runner(如 act_runner)。 - 无论是在 x86_64 服务器、云主机还是本地 Apple Silicon / ARM 设备上,Docker 都会自动拉取匹配本机架构的镜像运行。