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
+16 -4
View File
@@ -1,11 +1,14 @@
name: Build Docker Image Artifact name: Build Docker Image Artifact
on: on:
push:
branches:
- master
workflow_dispatch: workflow_dispatch:
inputs: inputs:
tag: tag:
description: '镜像标签版本' description: '镜像标签版本'
required: true required: false
default: 'latest' default: 'latest'
jobs: jobs:
@@ -40,17 +43,26 @@ jobs:
go mod tidy go mod tidy
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w' -o next-terminal ../main.go CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w' -o next-terminal ../main.go
- 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: Create package - name: Create package
run: | run: |
mkdir -p next-terminal mkdir -p next-terminal
cp server/next-terminal next-terminal/ cp server/next-terminal next-terminal/
cp config.yml.example next-terminal/config.yml cp config.yml.example next-terminal/config.yml
cp LICENSE next-terminal/ cp LICENSE next-terminal/
tar zcvf next-terminal-${{ inputs.tag }}-linux-amd64.tar.gz next-terminal/ tar zcvf next-terminal-${{ steps.version.outputs.VERSION }}-linux-amd64.tar.gz next-terminal/
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: next-terminal-${{ inputs.tag }}-linux-amd64 name: next-terminal-${{ steps.version.outputs.VERSION }}-linux-amd64
path: next-terminal-${{ inputs.tag }}-linux-amd64.tar.gz path: next-terminal-${{ steps.version.outputs.VERSION }}-linux-amd64.tar.gz
retention-days: 7 retention-days: 7
+17 -5
View File
@@ -1,11 +1,14 @@
name: Build Docker Image name: Build Docker Image
on: on:
push:
branches:
- master
workflow_dispatch: workflow_dispatch:
inputs: inputs:
tag: tag:
description: '镜像标签版本' description: '镜像标签版本'
required: true required: false
default: 'latest' default: 'latest'
jobs: jobs:
@@ -29,17 +32,26 @@ jobs:
yarn build yarn build
cp -r build ../server/resource/ 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 - name: Build Docker image
run: | run: |
docker build -t next-terminal:${{ inputs.tag }} . docker build -t next-terminal:${{ steps.version.outputs.VERSION }} .
- name: Save Docker image - name: Save Docker image
run: | 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 - name: Upload artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: next-terminal-docker-${{ inputs.tag }} name: next-terminal-docker-${{ steps.version.outputs.VERSION }}
path: next-terminal-${{ inputs.tag }}.tar.gz path: next-terminal-${{ steps.version.outputs.VERSION }}.tar.gz
retention-days: 7 retention-days: 7