-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
69 lines (62 loc) · 2.1 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
stages:
- build
- deploy
default:
before_script:
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- chmod 400 $DO_BE_BLR_SSH_KEY
- ssh-add $DO_BE_BLR_SSH_KEY
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $DO_BE_BLR_IP >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
workflow:
rules:
- if: $CI_COMMIT_BRANCH == 'dev'
when: always
- if: $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_BRANCH == 'main'
when: always
# if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'dev'
# when: always
# if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'master' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main'
# when: always
- when: never
build for development:
stage: build
rules:
# if: $CI_COMMIT_BRANCH == 'dev'
# if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'dev'
- when: never
environment: development
script:
- echo "Build script not configured for production"
build for production:
stage: build
rules:
- if: $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_BRANCH == 'main'
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'master' || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main'
- when: never
environment: production
script:
- echo "build script not configured for production"
deploy to development:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == 'dev'
- when: never
environment: development
script:
- echo "Running deploy script for development environment..."
- apt-get update -y
- apt-get -y install rsync
- ssh $DO_BE_BLR_CICD_USER@$DO_BE_BLR_IP "cd $DO_BE_BLR_DEV_DIR/wp-content/plugins/rc-woocommerce-headless/;bash ~/scripts/clean.sh;"
- rsync -ravztO --delete --exclude='.git*' . $DO_BE_BLR_CICD_USER@$DO_BE_BLR_IP:$DO_BE_BLR_DEV_DIR/wp-content/plugins/rc-woocommerce-headless
deploy to production:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_BRANCH == 'main'
- when: never
environment: production
script:
- echo "Deploy script not configured for production"