-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbitbucket-pipelines.yml
101 lines (94 loc) · 2.72 KB
/
bitbucket-pipelines.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
definitions:
services:
mariadb:
image: mariadb:10.3.11
environment:
MYSQL_DATABASE: "laravel"
MYSQL_PASSWORD: "secret"
MYSQL_ROOT_PASSWORD: "secret"
steps:
- step: &run_test
name: Testing Application
image: edbizarro/gitlab-ci-pipeline-php:7.4-alpine
script:
- cp src/.env.pipeline.bitbucket src/.env
- make fixing-cache
- make composer-install-cicd
- make key-generate
- make composer-dumpautoload
- make run-migrate-all
- make clear-all
services:
- mariadb
- step: &deploy
name: Deploy Server
deployment: staging
image: ruby:2.7.1-slim-buster
trigger: manual
unit_test: &unit_test
step:
<<: *run_test
deploy_staging: &deploy_staging
<<: *deploy
step:
name: Deploy Staging
deployment: staging
image: ruby:2.7.1-slim-buster
trigger: manual
script:
### SETUP SSH ###
- apt-get update -qq
- apt-get install -qq git build-essential
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- mkdir -p ~/.ssh
- echo "${MYAPP_SSH_PRIVATE_KEY}" | base64 --decode > ~/.ssh/id_rsa
- echo "${MYAPP_KNOWN_HOSTS}" | base64 --decode > ~/.ssh/known_hosts
- chmod 700 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- ssh-keyscan -H 'bitbucket.org' >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
### INSTALL LIBRARY ###
- gem install bundler
- bundle install
### DEPLOY ###
- make deploy-staging
deploy_production: &deploy_production
<<: *deploy
step:
name: Deploy Production
deployment: production
image: ruby:2.7.1-slim-buster
trigger: manual
script:
### SETUP SSH ###
- apt-get update -qq
- apt-get install -qq git build-essential
- 'which ssh-agent || ( apt-get install -qq openssh-client )'
- mkdir -p ~/.ssh
- echo "${MYAPP_SSH_PRIVATE_KEY}" | base64 --decode > ~/.ssh/id_rsa
- echo "${MYAPP_KNOWN_HOSTS}" | base64 --decode > ~/.ssh/known_hosts
- chmod 700 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- ssh-keyscan -H 'bitbucket.org' >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
### INSTALL LIBRARY ###
- gem install bundler
- bundle install
### DEPLOY ###
- make deploy-production
pipelines:
branches:
dev-staging:
# Test
- <<: *unit_test
# Deploy Staging
- <<: *deploy_staging
dev-master:
# Test
- <<: *unit_test
# Deploy Staging
- <<: *deploy_staging
# Deploy Production
- <<: *deploy_production