-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
134 lines (125 loc) · 3.66 KB
/
.gitlab-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
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
stages:
- test
- build
- deploy
- maintenance
test-backend:
stage: test
image: golang:latest
variables:
POSTGRES_DB: "aaryapaytest"
POSTGRES_USER: "postadmin"
POSTGRES_PASSWORD: "postpass"
MODE: "ci-test"
REDIS_HOST: redis
MP_SMTP_AUTH_ACCEPT_ANY: "true"
MP_SMTP_AUTH_ALLOW_INSECURE: "true"
services:
- name: postgres:13-alpine
alias: postgres
- name: redis:6-alpine
alias: redis
command: ["--requirepass redispass"]
- name: axllent/mailpit
alias: localhost
script:
- cd api
- go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
- migrate -source file://migrations -database=postgres://postadmin:postpass@postgres:5432/aaryapaytest\?sslmode=disable up
- go test ./...
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
changes:
- api/**/*
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-b$/'
changes:
- api/**/*
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
changes:
- api/**/*
test-client-lib:
stage: test
image: dart:latest
script:
- cd libaaryapay
- dart pub get
- dart test
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
changes:
- libaaryapay/**/*
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
changes:
- libaaryapay/**/*
build-backend:
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- echo $CI_BUILD_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
script:
- cd api
- docker build -t "$CI_REGISTRY_IMAGE/aaryapay-backend:$CI_COMMIT_TAG" -t "$CI_REGISTRY_IMAGE/aaryapay-backend:latest" .
- docker push $CI_REGISTRY_IMAGE/aaryapay-backend:$CI_COMMIT_TAG
- docker push $CI_REGISTRY_IMAGE/aaryapay-backend:latest
only:
refs:
- tags
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-b$/
build-file-server:
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- echo $CI_BUILD_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
script:
- cd file_server
- docker build -t "$CI_REGISTRY_IMAGE/aaryapay-file-server:$CI_COMMIT_TAG" -t "$CI_REGISTRY_IMAGE/aaryapay-file-server:latest" .
- docker push $CI_REGISTRY_IMAGE/aaryapay-file-server:$CI_COMMIT_TAG
- docker push $CI_REGISTRY_IMAGE/aaryapay-file-server:latest
only:
refs:
- tags
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-f$/
configs-sync:
image: alpine:latest
stage: deploy
script:
- apk add --no-cache openssh-client
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 -d)
- cd deployment
- ./sync-to-server.sh
- ssh -o StrictHostKeyChecking=no ubuntu@$SSH_DEPLOY_HOST "
echo $CI_BUILD_TOKEN | podman login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY &&
cd /home/ubuntu/aaryapay &&
./stop.sh &&
CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE ./start.sh
"
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
changes:
- deployment/**/*
- api/templates/**/*
- api/etc/**/*
ssh-deploy:
image: alpine:latest
stage: deploy
script:
- apk add --no-cache openssh-client
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 -d)
- ssh -o StrictHostKeyChecking=no ubuntu@$SSH_DEPLOY_HOST "
echo $CI_BUILD_TOKEN | podman login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY &&
cd /home/ubuntu/aaryapay &&
CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE ./update.sh
"
only:
refs:
- tags
variables:
- $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-b$/