-
Notifications
You must be signed in to change notification settings - Fork 147
/
.gitlab-ci.yml
79 lines (71 loc) · 2.08 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
image: node:14.21.3
stages:
- install
- build
- deploy
install:
stage: install
script:
- cd frontend
- npm install @angular/cli
- npm install
artifacts:
expire_in: 2 weeks
paths:
- frontend/node_modules/
cache:
paths:
- frontend/node_modules/
rules:
- if: $CI_PROJECT_NAMESPACE == 'kennbroorg' && $CI_PIPELINE_SOURCE == 'push'
build:
stage: build
dependencies:
- install
before_script:
- apt-get update -qy
- apt-get -y install zip unzip
script:
- cd frontend
- npm install @angular/cli
- npm install @angular-devkit/build-angular
- npm run build --prod
- cd ..
- mkdir -p /tmp/iKy-pack/frontend
- cp -r backend /tmp/iKy-pack
- cp requirements.txt /tmp/iKy-pack
- cp -r frontend/dist /tmp/iKy-pack/frontend
- mv /tmp/iKy-pack/backend/.README.md /tmp/iKy-pack/README.md
- cd /tmp
- zip -r iKy.zip ./iKy-pack
- mv /tmp/iKy.zip "$CI_PROJECT_DIR"
- cd $CI_PROJECT_DIR
artifacts:
expire_in: 2 weeks
paths:
- iKy.zip
rules:
- if: $CI_PROJECT_NAMESPACE == 'kennbroorg' && $CI_PIPELINE_SOURCE == 'push'
deploy:
stage: deploy
dependencies:
- build
before_script:
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git config --global user.name "${GITLAB_USER_NAME}"
- git clone git@gitlab.com:kennbroorg/ikyweb.git /tmp/page
- cp iKy.zip /tmp/page/file/iKy.zip
- cd /tmp/page
- git add file/iKy.zip
- git commit -m "iKy ZIP file from $CI_COMMIT_SHORT_SHA" || echo "No changes, nothing to commit!"
- git remote rm origin && git remote add origin git@gitlab.com:kennbroorg/ikyweb.git
- git push origin master
rules:
- if: $CI_PROJECT_NAMESPACE == 'kennbroorg' && $CI_PIPELINE_SOURCE == 'push'