mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 05:51:56 +08:00
74 lines
1.8 KiB
YAML
74 lines
1.8 KiB
YAML
name: Build Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
platform: [amd64, arm64]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
# 设置 Node.js 环境
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
|
|
# 安装 pnpm
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 8
|
|
|
|
# 安装依赖
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
# 构建前端项目
|
|
- name: Build frontend
|
|
run: pnpm build
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: linux/${{ matrix.platform }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: woodchen
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
# 添加缓存元数据
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: woodchen/clash-and-dashboard
|
|
tags: |
|
|
type=raw,value=latest
|
|
type=sha,prefix={{branch}}-
|
|
|
|
# 构建和推送
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./build/Dockerfile
|
|
platforms: linux/${{ matrix.platform }}
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=registry,ref=woodchen/clash-and-dashboard:buildcache-${{ matrix.platform }}
|
|
cache-to: type=registry,ref=woodchen/clash-and-dashboard:buildcache-${{ matrix.platform }},mode=max
|