78 lines
2.1 KiB
YAML
78 lines
2.1 KiB
YAML
name: Build Docker Image
|
|
|
|
concurrency:
|
|
group: ci
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: '镜像标签版本'
|
|
required: false
|
|
default: 'latest'
|
|
|
|
jobs:
|
|
lint:
|
|
name: Go Lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.22'
|
|
- name: Install golangci-lint
|
|
run: |
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.59.1
|
|
- name: Run golangci-lint
|
|
run: |
|
|
$(go env GOPATH)/bin/golangci-lint run --timeout=5m ./server/...
|
|
|
|
build:
|
|
name: Build Docker Image
|
|
needs: lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Build web
|
|
run: |
|
|
cd web
|
|
npm install --global yarn
|
|
yarn --frozen-lockfile --prefer-offline || yarn
|
|
node --max-old-space-size=4096 ./node_modules/.bin/vite build
|
|
cp -r dist ../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:${{ steps.version.outputs.VERSION }} .
|
|
|
|
- name: Save Docker image
|
|
run: |
|
|
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-${{ steps.version.outputs.VERSION }}
|
|
path: next-terminal-${{ steps.version.outputs.VERSION}}.tar.gz
|
|
retention-days: 7
|