fengling-console/.gitea/workflows/docker.yml
movingsam ecafe1984c
Some checks failed
Build and Push Docker / build (push) Failing after 29m44s
ci(workflows): 增加 Docker Buildx 设置步骤
- 在 GitHub Actions 工作流中添加 Docker Buildx 配置
- 使用最新的 moby/buildkit 镜像作为驱动选项
- 优化构建环境以支持多平台构建功能
2026-03-01 16:42:06 +08:00

78 lines
2.0 KiB
YAML

name: Build and Push Docker
on:
push:
branches: [main]
tags:
- "v*"
env:
REGISTRY: gitea.shtao1.cn
IMAGE_NAME: fengling/fengling-console
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
driver-opts: image=moby/buildkit:latest
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Extract version
id: version
run: |
VERSION=${{ github.ref_name }}
if [[ $VERSION == v* ]]; then
VERSION=${VERSION#v}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Login to Gitea
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: fengling
password: ${{ secrets.GITEATOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=${{ steps.version.outputs.version }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: src/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_VERSION=${{ steps.version.outputs.version }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move cache
if: always()
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache