feat: 添加自动构建触发,push到master时自动构建

This commit is contained in:
2026-04-18 17:06:32 +08:00
parent 18f8a52be8
commit e0fb44954b
2 changed files with 33 additions and 9 deletions
+17 -5
View File
@@ -1,11 +1,14 @@
name: Build Docker Image
on:
push:
branches:
- master
workflow_dispatch:
inputs:
tag:
description: '镜像标签版本'
required: true
required: false
default: 'latest'
jobs:
@@ -29,17 +32,26 @@ jobs:
yarn build
cp -r build ../server/resource/
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "VERSION=$(date +%Y%m%d-%H%M%S)" >> $GITHUB_OUTPUT
fi
- name: Build Docker image
run: |
docker build -t next-terminal:${{ inputs.tag }} .
docker build -t next-terminal:${{ steps.version.outputs.VERSION }} .
- name: Save Docker image
run: |
docker save next-terminal:${{ inputs.tag }} | gzip > next-terminal-${{ inputs.tag }}.tar.gz
docker save next-terminal:${{ steps.version.outputs.VERSION }} | gzip > next-terminal-${{ steps.version.outputs.VERSION }}.tar.gz
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: next-terminal-docker-${{ inputs.tag }}
path: next-terminal-${{ inputs.tag }}.tar.gz
name: next-terminal-docker-${{ steps.version.outputs.VERSION }}
path: next-terminal-${{ steps.version.outputs.VERSION }}.tar.gz
retention-days: 7