-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (46 loc) · 1.51 KB
/
Copy pathci.yml
File metadata and controls
48 lines (46 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: CI
on:
push: { branches: [main] }
pull_request: { branches: [main] }
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.26"
cache-dependency-path: server/go.sum
- name: Build & Vet
run: |
go build ./...
go vet ./...
- name: Test
run: go test ./...
# lockfile 一致性守卫(学习上游:依赖只改一半时 CI 即失败)
- name: Module verify
run: |
go mod verify
go mod download -x 2>&1 | tail -1
docker:
# main 推送时验证完整镜像(前端现场 npm ci 构建)
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { path: server }
- uses: actions/checkout@v4
with: { repository: filescodebox/frontend, path: frontend }
- name: 工作区布局 + ignore 规则
run: |
mkdir -p ${{ github.workspace }}/ws
mv server frontend ${{ github.workspace }}/ws/
printf '*/.git\n**/node_modules\n*/bin\n*/data\n*/logs\ngo.work\ngo.work.sum\n' > ${{ github.workspace }}/ws/.dockerignore
- uses: docker/setup-buildx-action@v3
- name: Build image(no push)
uses: docker/build-push-action@v6
with:
context: ${{ github.workspace }}/ws
file: ${{ github.workspace }}/ws/server/Dockerfile
push: false
tags: filecodebox-server:ci