diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml deleted file mode 100644 index a44dc24..0000000 --- a/.gitea/workflows/build.yaml +++ /dev/null @@ -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 . diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..bb5be7a --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/.gitignore b/.gitignore index 897a9b0..77bd586 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ Thumbs.db *.log .codegraph/ .omo/ +.idea/ diff --git a/README.md b/README.md index 7536a80..2dd2b31 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ 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` -- 确保 Gitea 仓库已启用 Actions 且部署有对应 Runner(如 act_runner)。 +- **Registry**: `ghcr.io/567ai/webman-docker:latest`(或对应 tag 如 `:v1.0.0`) +- 无论是在 x86_64 服务器、云主机还是本地 Apple Silicon / ARM 设备上,Docker 都会自动拉取匹配本机架构的镜像运行。