ci(workflows): 优化Docker构建及推送流程
Some checks failed
Build and Push Docker / build (push) Failing after 4m19s

- 更新Docker镜像仓库地址为内部私有地址
- 修改buildx驱动配置,允许不安全权限项
- 修正登录动作中秘钥参数名为GITEA_TOKEN
- 简化缓存目录移动脚本,确保缓存正确更新
- 关闭构建溯源信息生成以提升构建速度
This commit is contained in:
movingsam 2026-03-01 22:14:51 +08:00
parent bad0de9f3b
commit ac0776cc9c

View File

@ -1,27 +1,23 @@
name: Build and Push Docker name: Build and Push Docker
on: on:
push: push:
branches: [main] branches: [main]
tags: tags:
- "v*" - "v*"
env: env:
REGISTRY: gitea.shtao1.cn REGISTRY: 192.168.100.120:8418
IMAGE_NAME: fengling/fengling-console IMAGE_NAME: fengling/fengling-console
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
with: with:
driver: docker-container driver: docker-container
driver-opts: image=moby/buildkit:latest driver-opts: image=moby/buildkit:latest
buildkitd-flags: --allow-insecure-entitlement security.insecure
- name: Cache Docker layers - name: Cache Docker layers
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
@ -37,14 +33,12 @@ jobs:
VERSION=${VERSION#v} VERSION=${VERSION#v}
fi fi
echo "version=$VERSION" >> $GITHUB_OUTPUT echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Login to Registry
- name: Login to Gitea
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ env.REGISTRY }} registry: ${{ env.REGISTRY }}
username: fengling username: fengling
password: ${{ secrets.GITEATOKEN }} password: ${{ secrets.GITEA_TOKEN }}
- name: Extract metadata - name: Extract metadata
id: meta id: meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
@ -55,7 +49,6 @@ jobs:
type=sha,prefix= type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}} type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=${{ steps.version.outputs.version }} type=raw,value=${{ steps.version.outputs.version }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
@ -68,10 +61,9 @@ jobs:
BUILD_VERSION=${{ steps.version.outputs.version }} BUILD_VERSION=${{ steps.version.outputs.version }}
cache-from: type=local,src=/tmp/.buildx-cache cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
provenance: false
- name: Move cache - name: Move cache
if: always() if: always()
run: | run: |
rm -rf /tmp/.buildx-cache rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache mv /tmp/.buildx-cache-new /tmp/.buildx-cache