-
Notifications
You must be signed in to change notification settings - Fork 2
129 lines (105 loc) · 3.02 KB
/
server-build.yml
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
name: server build/publish
env:
GO_VERSION: "^1.22.0"
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{env.GO_VERSION}}
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.56.2
working-directory: server
skip-cache: true
args: --timeout=5m
test:
runs-on: ubuntu-latest
env:
working-directory: ./server
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{env.GO_VERSION}}
- name: Set up gotestfmt
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
- name: Run tests
working-directory: ${{env.working-directory}}
run: |
set -euo pipefail
go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt -hide "empty-packages"
build:
runs-on: ubuntu-latest
env:
working-directory: ./server
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{env.GO_VERSION}}
- name: Build
working-directory: ${{env.working-directory}}
run: make build
- name: Generate data
working-directory: ${{env.working-directory}}
run: make init.all generate.artifacts
- name: Store binaries
uses: actions/upload-artifact@v3
with:
name: server-binaries
path: ${{env.working-directory}}/bin
retention-days: 1
- name: Store generated data
uses: actions/upload-artifact@v3
with:
name: server-data
path: ${{env.working-directory}}/var/gen
retention-days: 1
publish:
runs-on: ubuntu-latest
needs:
- build
- test
if: ${{ github.ref == 'refs/heads/main' }}
env:
working-directory: ./server
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download server binaries
uses: actions/download-artifact@v3
with:
name: server-binaries
path: ${{env.working-directory}}/bin
- name: Download generated data
uses: actions/download-artifact@v3
with:
name: server-data
path: ${{env.working-directory}}/var/gen
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push server
uses: docker/build-push-action@v4
with:
context: ./server
push: true
tags: warmans/rsk-search-api:latest