This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
forked from wjclub/telegram-bot-getids
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
89 lines (83 loc) · 2 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
stages:
- review
- staging
- production
deploy_review:
stage: review
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://t.me/IDontknow
only:
- branches
except:
- master
script:
- echo "Deploy a review app"
Deploy staging version:
stage: staging
environment:
name: staging
url: https://t.me/GetIDsStagingBot
on_stop: Stop staging version
only:
- master
tags:
- sh14
variables:
SERVICE_FILE: telegram-bot-getids-staging.ini
SERVICE_NAME: telegram-bot-getids-staging
NODE_PATH: /usr/bin/node
DIRECTORY: /home/sh14/telegram-bot-getids-staging
script:
- cp supervisord-service.ini $SERVICE_FILE
- sed -i "s#VAR_SERVICE_NAME#$SERVICE_NAME#g" $SERVICE_FILE
- sed -i "s#VAR_NODE_PATH#$NODE_PATH#g" $SERVICE_FILE
- sed -i "s#VAR_DIRECTORY#$DIRECTORY#g" $SERVICE_FILE
- sed -i "s#VAR_BOT_TOKEN#$BOT_ID_STAGING:$BOT_TOKEN_STAGING#g" $SERVICE_FILE
- mkdir -p $SERVICE_DIR_STAGING
- mv $SERVICE_FILE $SERVICE_DIR_STAGING$SERVICE_FILE
- rm -rf $DIRECTORY
- mkdir -p $DIRECTORY
- mv $(pwd)/* "$DIRECTORY"
- cd "$DIRECTORY"
- npm update
- supervisorctl reread && supervisorctl update && supervisorctl status
Stop staging version:
stage: staging
tags:
- sh14
when: manual
environment:
name: staging
action: stop
variables:
SERVICE_FILE: telegram-bot-getids-staging.ini
SERVICE_NAME: telegram-bot-getids-staging
DIRECTORY: /home/sh14/telegram-bot-getids-staging
script:
- rm $SERVICE_DIR_STAGING$SERVICE_FILE
- supervisorctl reread && supervisorctl update && supervisorctl status
- rm -rf $DIRECTORY
Deploy to production:
stage: production
when: manual
dependencies:
- Deploy staging version
environment:
name: production
url: https://t.me/GetIDsBot
on_stop: Stop production version
only:
- master
script:
- echo ""
Stop production version:
stage: production
tags:
- prodserver
when: manual
environment:
name: production
action: stop
script:
- echo ""