-
Notifications
You must be signed in to change notification settings - Fork 22
143 lines (118 loc) · 3.26 KB
/
Copy pathci.yml
File metadata and controls
143 lines (118 loc) · 3.26 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: CI
on:
push:
branches: [ main ]
tags:
- 'v*'
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- 'web/**'
- 'ent/**'
- 'Dockerfile'
- '.github/workflows/ci.yml'
pull_request:
branches: [ main ]
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- 'web/**'
- 'ent/**'
- '.github/workflows/ci.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
cache-dependency-path: go.sum
- name: Enable Corepack (pnpm)
run: corepack enable
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: web/pnpm-lock.yaml
- name: Frontend install
working-directory: web
run: pnpm install --frozen-lockfile
- name: Frontend lint
working-directory: web
run: pnpm lint
- name: Frontend format check
working-directory: web
run: pnpm format:check
- name: Frontend build
working-directory: web
run: pnpm build
- name: Download Go dependencies
run: go mod download
- name: Install swag
run: go install github.com/swaggo/swag/cmd/swag@latest
- name: Generate code (ent & swagger)
run: go generate ./...
- name: Go fmt check
run: |
DIFF=$(gofmt -l .)
if [ -n "$DIFF" ]; then
echo "Files not formatted:"
echo "$DIFF"
exit 1
fi
- name: Go vet
run: go vet ./...
- name: Run tests
run: go test -v ./...
release:
runs-on: ubuntu-latest
needs: [ check ]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- name: Get version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.VERSION }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max