-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (90 loc) · 2.73 KB
/
ci.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
name: 2024_2_ThereWillBeName build
on:
push:
branches:
- main
- dev
jobs:
linters-act:
name: linters
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- uses: actions/checkout@v3
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.mod', '**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-mod-
- name: Install dependencies
run: go mod tidy
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
tests-act:
name: tests
needs: linters-act
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.mod', '**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-mod-
- name: Build gateway
run: go build -v ./cmd/gateway/main.go
- name: Build attraction
run: go build -v ./cmd/attractions/main.go
- name: Build trips
run: go build -v ./cmd/trips/main.go
- name: Build users
run: go build -v ./cmd/users/main.go
- name: Test
run: go test -v -race ./...
deploy:
name: Deploy 2024_2_ThereWillBeName
needs: tests-act
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Pull code
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: cd /home/ubuntu/2024_2_ThereWillBeName && git pull
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Build containers
uses: appleboy/ssh-action@master
with:
command_timeout: 20m
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
cd /home/ubuntu/2024_2_ThereWillBeName && sudo docker-compose build --no-cache
- name: Restart service
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
cd /home/ubuntu/2024_2_ThereWillBeName && sudo docker-compose down && sudo docker-compose up -d