-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
87 lines (81 loc) · 1.95 KB
/
.gitlab-ci.yml
File metadata and controls
87 lines (81 loc) · 1.95 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
---
image: cimg/ruby:3.4.3-browsers
variables:
POSTGRES_HOST: postgres
POSTGRES_DB: thape_web_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
CACHE_FALLBACK_KEY: "$CI_COMMIT_REF_SLUG"
before_script:
- bundle config set path 'vendor' # Install dependencies into ./vendor/ruby
- |
if ! command -v pnpm >/dev/null; then
if command -v corepack >/dev/null; then
corepack enable
corepack prepare pnpm@9.0.0 --activate
elif command -v npm >/dev/null; then
npm install -g pnpm@9.0.0
else
echo 'pnpm is required but neither corepack nor npm is available.' >&2
exit 1
fi
fi
stages:
- test
- deploy
test:
services:
- postgres:12.9
stage: test
cache:
- key:
files:
- Gemfile.lock
paths:
- vendor/ruby
variables:
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB
script:
- bundle install -j $(nproc)
- pnpm install --frozen-lockfile
- cp config/database.yml.sample.yaml config/database.yml
- bin/rails db:drop RAILS_ENV=test
- bin/rails db:setup RAILS_ENV=test
- bin/rails test
deploy_staging:
cache:
- key:
files:
- Gemfile.lock
paths:
- vendor/ruby
stage: deploy
script:
- bundle install -j $(nproc)
- mkdir ~/.ssh
- mv "$SSH_ID_RSA" ~/.ssh/id_rsa
- mv "$SSH_CONFIG_FILE" ~/.ssh/config
- bundle exec cap staging deploy
environment:
name: staging
url: https://tailwind.thape.com.cn
deploy_production:
cache:
- key:
files:
- Gemfile.lock
paths:
- vendor/ruby
stage: deploy
script:
- bundle install -j $(nproc)
- mkdir ~/.ssh
- mv "$SSH_ID_RSA" ~/.ssh/id_rsa
- mv "$SSH_CONFIG_FILE" ~/.ssh/config
- bundle exec cap production deploy
environment:
name: production
url: https://www.thape.com
when: manual
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH