-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (89 loc) · 2.82 KB
/
deploy.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
name: BogoSort_2024_2 Deploy
on:
push:
branches: [main, develop, 'TP-*']
pull_request:
branches: [main]
jobs:
run-linters:
name: run-linters
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out code into directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: 1.23
id: go
- name: Cache Go modules
uses: actions/cache@v2
with:
path: /tmp/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ github.sha }}
${{ runner.os }}-go-
- name: Install required dependencies
run: go mod tidy
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: latest
working-directory: .
args: -c ./.golangci.yaml
run-tests:
name: run-tests
needs: run-linters
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Cache Go modules
uses: actions/cache@v2
with:
path: /tmp/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ github.sha }}
${{ runner.os }}-go-
- name: Get Dependencies
run: go get ./...
- name: Build Application
run: go build ./...
- name: Run Tests
run: |
go test -json ./... -coverprofile coverprofile_.tmp -coverpkg=./... ; \
grep -v -e '/mocks' -e 'mock_repository.go' -e 'mock.go' -e 'docs.go' -e '_easyjson.go' -e '.pb.go' -e 'gen.go' -e '/cmd/' -e '/config/' -e '/pkg/connector/' coverprofile_.tmp > coverprofile.tmp ; \
rm coverprofile_.tmp ; \
go tool cover -html coverprofile.tmp -o ../heatmap.html; \
go tool cover -func coverprofile.tmp
deploy:
name: deploy to server
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
needs: [run-linters, run-tests]
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Deploy to Server
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
debug: true
script: |
cd /home/${{ secrets.USERNAME }}/2024_2_BogoSort
git checkout develop
git fetch && git pull
sudo docker-compose build
sudo docker-compose down
sudo docker-compose up -d --build --remove-orphans