-
Notifications
You must be signed in to change notification settings - Fork 7
115 lines (112 loc) · 3.24 KB
/
rubyonrails.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: "CI-CD"
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
security:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
bundler-cache: true
- name: Security audit dependencies
run: bundle exec bundler-audit --update
- name: Security audit application code
run: bundle exec brakeman -q -w2
lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
- name: Install packages
run: |
bundle config set --local only test
bundle install
- name: Lint Ruby files
run: rubocop --fail-fast
test:
needs:
- security
- lint
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:17.2-alpine
ports:
- "5432:5432"
env:
POSTGRES_DB: rails_test
POSTGRES_USER: rails
POSTGRES_PASSWORD: password
env:
CI: true
RAILS_ENV: test
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
TZ: "Europe/Moscow"
COVERAGE: on
BULLET_ENABLED: true
APP_HOST: "test.ru"
ADMIN_EMAIL: "[email protected]"
INFO_EMAIL: "[email protected]"
BOT_TOKEN: "123456:test"
VK_TOKEN: ${{ secrets.VK_TOKEN }}
VK_ALBUM_ID: 300954831
VK_GROUP_ID: 220002708
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y libvips
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
bundler-cache: true
- name: Set up database schema
run: cp config/additional_events.yml.example config/additional_events.yml && bin/rails db:schema:load
- name: Check database consistency
run: bundle exec database_consistency
- name: Rspec tests
if: github.ref != 'refs/heads/master'
run: bundle exec rspec
- name: Test & publish code coverage
if: github.ref == 'refs/heads/master'
uses: paambaati/codeclimate-action@v9
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE }}
with:
coverageCommand: bundle exec rspec
deploy:
if: github.ref == 'refs/heads/master'
needs:
- test
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
bundler-cache: true
- name: Deploy
uses: miloserdow/capistrano-deploy@master
with:
target: production
deploy_key: ${{ secrets.DEPLOY_ENC_KEY }}
env:
APP_NAME: ${{ secrets.APP_NAME }}
APP_REPO: ${{ secrets.APP_REPO }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
APP_DEPLOY_PATH: ${{ secrets.APP_DEPLOY_PATH }}