generated from Sebastix/cchs.social
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
113 lines (105 loc) · 4.07 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
image: php:8.3-alpine
variables:
# Production
DRUPAL_PROJECTROOT_PROD: "/var/www/vhosts/sebastix.nl/ccns"
URL_PROD: "https://ccns.social"
SSH_LOGIN_PROD: "ssh -T [email protected]"
SSH_USER_PROD: "sebastix"
SSH_HOST_PROD: "ximo1.ximology.com"
workflow:
rules:
# Pipelines do not run when branchname starts with ^aupdt_
- if: $CI_COMMIT_BRANCH =~ /^aupdt_/
when: never
- when: always
stages:
- build
- test
- deploy
before_script:
- 'which ssh-agent || ( apk add --update openssh )'
- apk add --update bash
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY_PROD" | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
# Install rsync
- apk add rsync
- rsync --version
# Install curl
- apk add curl
# Install composer
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
- alias composer='php /usr/bin/composer'
- composer --version
# Install nodejs and npm
- apk add nodejs npm
- node --version
- npm --version
# install php extensions
# - see https://github.com/mlocati/docker-php-extension-installer
- curl -sSLf -o /usr/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
- chmod +x /usr/bin/install-php-extensions
- install-php-extensions gd gmp
# install git
- apk add git
build:drupal:
stage: build
script:
- composer install --no-dev --prefer-dist --optimize-autoloader
artifacts:
paths:
- web
- vendor
build:nostr-ndk:
stage: build
script:
- cd web/modules/custom/nostr_ndk
- npm install
- npm run build
artifacts:
paths:
- web/modules/custom/nostr_ndk/dist
build:theme:
stage: build
script:
- cd web/themes/custom/ccns_theme
- npm install
- npm run build
artifacts:
paths:
- web/themes/custom/ccns_theme/dist
deploy:prod:
rules:
- if: $CI_COMMIT_BRANCH == "develop"
when: manual
- if: $CI_COMMIT_BRANCH == "master"
when: manual
stage: deploy
environment:
name: production
url: $URL_PROD
dependencies:
- build:drupal
- build:nostr-ndk
- build:theme
script:
- rsync -avz -e ssh ./composer.json $SSH_USER_PROD@$SSH_HOST_PROD:$DRUPAL_PROJECTROOT_PROD
- rsync -avz -e ssh ./composer.lock $SSH_USER_PROD@$SSH_HOST_PROD:$DRUPAL_PROJECTROOT_PROD
- rsync -avq --delete --exclude-from='gitlab-ci/rsync-excludes.txt' -e ssh ./config $SSH_USER_PROD@$SSH_HOST_PROD:$DRUPAL_PROJECTROOT_PROD
- rsync -avq --delete --exclude-from='gitlab-ci/rsync-excludes.txt' -e ssh ./vendor $SSH_USER_PROD@$SSH_HOST_PROD:$DRUPAL_PROJECTROOT_PROD
- $SSH_LOGIN_PROD "cd $DRUPAL_PROJECTROOT_PROD && chmod -R 755 ./config"
- rsync -avq --delete --exclude-from='gitlab-ci/rsync-excludes.txt' -e ssh ./web $SSH_USER_PROD@$SSH_HOST_PROD:$DRUPAL_PROJECTROOT_PROD
- rsync -azq --delete --exclude-from='gitlab-ci/rsync-excludes.txt' -e ssh web/modules/custom $SSH_USER_PROD@$SSH_HOST_PROD:$DRUPAL_PROJECTROOT_PROD/web/modules
- rsync -azq --delete --exclude-from='gitlab-ci/rsync-excludes.txt' -e ssh web/themes/custom $SSH_USER_PROD@$SSH_HOST_PROD:$DRUPAL_PROJECTROOT_PROD/web/themes
- $SSH_LOGIN_PROD "cd $DRUPAL_PROJECTROOT_PROD && chmod -R 755 ./web"
- $SSH_LOGIN_PROD "cd $DRUPAL_PROJECTROOT_PROD && chmod -R 444 ./web/sites/default/settings.php"
- $SSH_LOGIN_PROD "cd $DRUPAL_PROJECTROOT_PROD && chmod -R 444 ./web/sites/default/settings.local.php"
- $SSH_LOGIN_PROD "$DRUPAL_PROJECTROOT_PROD/vendor/bin/drush updatedb -y"
- $SSH_LOGIN_PROD "$DRUPAL_PROJECTROOT_PROD/vendor/bin/drush cache-rebuild -y"
- $SSH_LOGIN_PROD "$DRUPAL_PROJECTROOT_PROD/vendor/bin/drush config-import -y"
- $SSH_LOGIN_PROD "$DRUPAL_PROJECTROOT_PROD/vendor/bin/drush core-cron"
- $SSH_LOGIN_PROD "$DRUPAL_PROJECTROOT_PROD/vendor/bin/drush ckeditor5_markdown_editor:install"
- $SSH_LOGIN_PROD "$DRUPAL_PROJECTROOT_PROD/vendor/bin/drush cache-rebuild -y"
- echo "Deployment ready, check $URL_PROD"