-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (68 loc) · 1.74 KB
/
ci.yaml
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
name: "CI"
on:
push:
branches:
- '*'
tags:
- ''
pull_request:
branches:
- '*'
jobs:
test:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: aweme
MYSQL_USER: aweme
MYSQL_PASSWORD: aweme
ports:
- 3306:3306
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Code Generation
run: |
MOCKERY=1 sh ./scripts/codegen.sh
- name: Go Code Test
run: |
go mod tidy
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage.txt
- name: Go Build
run: |
go build -ldflags="-w -s" -o app cmd/aweme/main.go
container:
runs-on: ubuntu-latest
needs: [ test ]
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Code Generation
run: |
sh ./scripts/codegen.sh
- name: Login to DockerHub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./scripts/Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{ secrets.DOCKERHUB_USERNAME || 'aweme' }}/aweme:latest