fengling-console/.gitea/workflows/docker.yml
movingsam f163d6c92a
Some checks failed
Build and Push Docker / build (push) Failing after 47m55s
fix(ci): 使用本地文件系统缓存替代GitHub Actions缓存
- 将 cache type 从 gha 改为 local
- 缓存路径设为 /data/.buildx-cache (Runner持久化目录)
- 添加 Move cache 步骤防止缓存损坏
2026-03-01 14:15:32 +08:00

67 lines
1.7 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
- 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=/data/.buildx-cache
cache-to: type=local,dest=/data/.buildx-cache-new,mode=max
- name: Move cache
run: |
rm -rf /data/.buildx-cache
mv /data/.buildx-cache-new /data/.buildx-cache