-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
167 lines (160 loc) · 4.85 KB
/
.gitlab-ci.yml
File metadata and controls
167 lines (160 loc) · 4.85 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
---
image:
name: docker-web.cdek.ru/phnodenx-dev-rocky9-8.2
entrypoint: ['']
#
stages:
- sync
- build
- test
- upload
- deploy
build_tag:
image: docker-proxy.cdek.ru/php:8.2-alpine
stage: build
tags:
- docker
only:
- tags
before_script:
- export RELEASE_VERSION=$(echo "${CI_COMMIT_TAG}" | sed 's/v//')
- sed -i 's/dl-cdn.alpinelinux.org/repo.cdek.ru\/repository/g' /etc/apk/repositories
- apk add nodejs-current yarn
- curl -v -sS https://getcomposer.org/installer | php
- mv composer.phar /usr/local/bin/composer
- corepack enable
script:
- sed -i "s/\(Version:\)\( *\).*/\1\2${RELEASE_VERSION}/" cdek.php
- sed -i "s/\(Stable tag:\)\( *\).*/\1\2${RELEASE_VERSION}/" README.md
- sed -i "s/\(Project-Id-Version:\)\( *\).*/\1\2CDEKDelivery ${RELEASE_VERSION}\"/" lang/cdekdelivery.pot
- yarn
- yarn build
- rm -rf node_modules
- composer remove --no-install --ignore-platform-req=ext-gmp composer/installers
- composer i -a --no-dev --ignore-platform-req=ext-gmp
- composer archive -f zip --file=cdek
artifacts:
name: cdek-integration
paths:
- cdek.zip
build_custom:
image: docker-proxy.cdek.ru/php:8.2-alpine
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
- when: manual
stage: build
tags:
- docker
artifacts:
name: cdek-integration
paths:
- cdek.zip
before_script:
- !reference [build_tag, before_script]
- export RELEASE_VERSION="${CI_COMMIT_REF_NAME}#${CI_COMMIT_SHORT_SHA}"
script:
- !reference [build_tag, script]
upload:
stage: upload
tags:
- docker
needs:
- job: build_tag
artifacts: true
only:
- tags
before_script:
- export RELEASE_VERSION=$(echo "${CI_COMMIT_TAG}" | sed 's/v//')
- export ARCHIVE_VERSION=$(echo "${RELEASE_VERSION}" | sed 's/\./_/g')
script:
- curl -u "${NEXUS_LOGIN}":"${NEXUS_PASS}" --upload-file cdek.zip "${ARTIFACTORY_REPO}/$CI_PROJECT_NAME/$CI_COMMIT_BRANCH/wordpress_${ARCHIVE_VERSION}.zip"
release:
stage: deploy
tags:
- docker
needs:
- job: upload
only:
- tags
image: registry-gitlab.cdek.ru/gitlab-org/release-cli:latest
before_script:
- export RELEASE_VERSION=$(echo "${CI_COMMIT_TAG}" | sed 's/v//')
- export ARCHIVE_VERSION=$(echo "${RELEASE_VERSION}" | sed 's/\./_/g')
script:
- |
release-cli create --name $CI_COMMIT_TAG --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"Архив\",\"filepath\":\"/archive\",\"url\":\"${ARTIFACTORY_REPO}$CI_COMMIT_BRANCH/$CI_PROJECT_NAME/wordpress_${ARCHIVE_VERSION}.zip\", \"link_type\":\"package\"}" \
deploy_staging:
stage: deploy
image: docker-proxy.cdek.ru/alpine
script:
- rsync -avz -e "ssh -o StrictHostKeyChecking=no" --delete ./cdek.zip ${DEPLOY_USERNAME}@${DEPLOY_NODE}:${DEPLOY_DEST_DIR}/plugins
- ssh ${DEPLOY_USERNAME}@${DEPLOY_NODE} "cd ${DEPLOY_DEST_DIR}/core && docker compose restart app"
tags:
- docker
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
- when: never
needs:
- job: build_custom
artifacts: true
environment:
name: dev2
url: https://wordpress-cms.dev2.cdek.ru
before_script:
- sed -i 's/dl-cdn.alpinelinux.org/repo.cdek.ru\/repository/g' /etc/apk/repositories
- test -r ~/.ssh || mkdir -p ~/.ssh
- 'command -v ssh-agent >/dev/null || ( apk update && apk add openssh-client )'
- 'command -v rsync >/dev/null || ( apk update && apk add rsync )'
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- eval $(ssh-agent -s)
- ssh-add ~/.ssh/id_rsa
github:
image: docker-proxy.cdek.ru/alpine
stage: sync
tags:
- docker
rules:
- if: $CI_COMMIT_REF_PROTECTED != "true"
when: never
- if: $CI_COMMIT_TAG
when: never
- when: always
before_script:
- test -r ~/.ssh || mkdir -p ~/.ssh
- echo "$SSH_CONFIG" > ~/.ssh/config
- echo "$GITHUB_DEPLOY_KEY" > ~/.ssh/id_integrator
- chmod 400 ~/.ssh/id_integrator
- sed -i 's/dl-cdn.alpinelinux.org/repo.cdek.ru\/repository/g' /etc/apk/repositories
- apk add --no-cache git netcat-openbsd openssh-client git-lfs
- git config checkout.defaultRemote origin
- git remote add -f github "${GITHUB_REPO}" || true
script:
- git branch -D $CI_COMMIT_REF_NAME || true
- git checkout --track origin/$CI_COMMIT_REF_NAME
- git pull -f --unshallow
- git fetch github $CI_COMMIT_REF_NAME
- git branch -u github/$CI_COMMIT_REF_NAME
- git push
sonarqube-check:
image:
name: docker-proxy.cdek.ru/sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
GIT_DEPTH: "0"
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
tags:
- docker
stage: test
script:
- sonar-scanner
allow_failure: true
only:
- main