31 lines
859 B
YAML
31 lines
859 B
YAML
name: 构建并运行 Docker
|
||
|
||
on:
|
||
push:
|
||
tags:
|
||
- 'v*' # 只在以 build-v 开头的 tag(如 build-v1.0.0)时触发
|
||
|
||
jobs:
|
||
build:
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: 释放内存
|
||
run: docker system prune -a -f
|
||
|
||
- name: 拉取自定义 checkout action
|
||
run: git clone http://114.67.155.184:3000//niyyzf/checkout.git ./.actions/checkout
|
||
|
||
- name: 检出代码
|
||
uses: ./.actions/checkout
|
||
with:
|
||
fetch-depth: 1
|
||
persist-credentials: false
|
||
max-attempts: 5
|
||
|
||
- name: 构建 Docker 镜像
|
||
run: docker build --cache-from type=gha --cache-to type=gha,mode=max -t watch-stock-list:latest .
|
||
|
||
- name: 启动/重启服务(Docker Compose)
|
||
run: |
|
||
docker compose down || true
|
||
docker compose up -d --force-recreate |