Files
managepro-docker/.gitea/workflows/build.yaml
T
Antigravity f364821128
Build and Push Docker Image / build (push) Successful in 32m34s
feat(ci): 支持 docker buildx 多架构构建 (linux/amd64,linux/arm64)
2026-09-19 13:31:26 +08:00

58 lines
1.7 KiB
YAML

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 .