-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
134 lines (124 loc) · 3.54 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:
- build
- SecurityChecker
- CodingStandards
- UnitTests
- deploy
cache:
paths:
- vendor/
- node_modules/
build-php:
stage: "build"
only:
- main
- tests
artifacts:
paths:
- ./
image: chibyjade/php-8.0:latest
script:
- APP_ENV=test composer install --prefer-dist --optimize-autoloader --classmap-authoritative --no-interaction --no-ansi
- mkdir -p var && chmod -R 777 var && chmod +x -R bin
build-js:
stage: "build"
only:
- main
- tests
artifacts:
paths:
- ./
image: node:current-alpine3.15
script:
- yarn install
- yarn build
build-docker:
stage: "build"
only:
- main
image: docker:20.10.12-alpine3.15
services:
- docker:20.10.12-dind-alpine3.15
variables:
IMAGE_NAME: chibyjade/guestbook
IMAGE_TAG: ${CI_PIPELINE_ID}
APP_VERSION: ${IMAGE_TAG}
GIT_COMMIT: ${CI_COMMIT_SHA}
script:
- echo ${DOCKER_PWD} | docker login -u ${DOCKER_LOGIN} --password-stdin
- docker info
- docker build -t ${IMAGE_NAME}:${IMAGE_TAG} --build-arg CORS_ALLOW_ORIGIN --build-arg MAILER_DSN --build-arg APP_VERSION --build-arg GIT_COMMIT --build-arg MESSENGER_TRANSPORT_DSN --build-arg APP_MAINTENANCE --build-arg APP_ENV --build-arg POSTGRES_SERVER_VERSION --build-arg POSTGRES_CHARSET --build-arg POSTGRES_DRIVER --build-arg POSTGRES_HOST --build-arg POSTGRES_PORT .
- chmod +x ./ci/docker-tag.sh && ./ci/docker-tag.sh
- docker push ${IMAGE_NAME}
# security-checker:
# stage: SecurityChecker
# needs: ["build-php"]
# only:
# - main
# - tests
# image: jakzal/phpqa:php8.0-alpine
# script:
# - local-php-security-checker --path=./composer.lock
# allow_failure: false
# phpcs:
# stage: CodingStandards
# needs: ["build-php"]
# only:
# - main
# - tests
# image: jakzal/phpqa:php8.0-alpine
# script:
# - phpcs -v --standard=PSR12 --ignore=./src/Kernel.php ./src
# allow_failure: false
phpstan:
stage: CodingStandards
needs: ["build-php"]
only:
- main
- tests
image: jakzal/phpqa:php8.0-alpine
script:
- phpstan analyse ./src
allow_failure: false
twig-lint:
needs: ["build-php"]
stage: CodingStandards
only:
- main
- tests
image: jakzal/phpqa:php8.0-alpine
script:
- twig-lint lint ./templates
allow_failure: false
# phpunit:
# stage: UnitTests
# needs: ["build-php"]
# only:
# - main
# - tests
# image: chibyjade/php-8.0:latest
# services:
# - postgres:13-alpine
# variables:
# POSTGRES_HOST_AUTH_METHOD: trust
# DATABASE_URL: 'postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres:5432/$POSTGRES_DB?serverVersion=13&charset=utf8'
# script:
# - make tests
# allow_failure: false
deploy:
stage: "deploy"
only:
- main
image: alpine:3.15
script:
- 'which ssh-agent || ( apk -U upgrade && apk add openssh-client )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\nStrictHostKeyChecking no\n" > ~/.ssh/config'
- ssh-add <(echo "$DEPLOYER_PK")
- scp -p docker-compose.yml $DEPLOYER_USERNAME@$PRODUCTION_SERVER_IP:$PRODUCTION_SERVER_PATH
- scp -p docker-compose.prod.yml $DEPLOYER_USERNAME@$PRODUCTION_SERVER_IP:$PRODUCTION_SERVER_PATH
- scp -p ci/deploy.sh $DEPLOYER_USERNAME@$PRODUCTION_SERVER_IP:$PRODUCTION_SERVER_PATH
- scp -p ci/run.sh $DEPLOYER_USERNAME@$PRODUCTION_SERVER_IP:$PRODUCTION_SERVER_PATH
- ssh $DEPLOYER_USERNAME@$PRODUCTION_SERVER_IP "cd $PRODUCTION_SERVER_PATH && chmod +x ./deploy.sh && chmod +x ./run.sh"
- chmod +x ci/ssh.sh && ci/ssh.sh