99 lines
2.5 KiB
YAML
99 lines
2.5 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: act-runner-4c6g
|
|
container:
|
|
image: golang:1.22
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- 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-web:
|
|
name: Build Web
|
|
needs: lint
|
|
runs-on: act-runner-4c6g
|
|
container:
|
|
image: node:20
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- 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
|
|
mkdir -p ../server/resource/build
|
|
cp -r dist/* ../server/resource/build/
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: web-build
|
|
path: server/resource/build
|
|
|
|
build-docker:
|
|
name: Build Docker Image
|
|
needs: build-web
|
|
runs-on: act-runner-4c6g
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download build artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: web-build
|
|
path: server/resource/build
|
|
|
|
- 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: Docker Setup Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: gitea.viaeon.com
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.CI_TOKEN }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
gitea.viaeon.com/${{ github.repository }}:${{ steps.version.outputs.VERSION }}
|
|
gitea.viaeon.com/${{ github.repository }}:latest
|