-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (98 loc) · 3.09 KB
/
main.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
116
117
118
119
120
121
122
123
name: CI & CD
on: [push]
env:
RAILS_ENV: test
CI: true
jobs:
test:
name: Run RSpec
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: opencourts_api_test
RAILS_ENV: test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup ENV File
run: mv .env.ci .env.test
- name: Install Required Packages
run: sudo apt-get install libpq-dev libssl-dev libcurl4 libcurl4-openssl-dev
- name: 'Read Ruby Version'
id: read-ruby-version
run: echo "RUBY_VERSION=$(cat .ruby-version)" >> $GITHUB_OUTPUT
- uses: ruby/setup-ruby@v1
with:
ruby-version: '${{ steps.read-ruby-version.outputs.RUBY_VERSION }}'
bundler-cache: true
- name: Install Bundle
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Install Yarn
run: npm install -g yarn
- name: Install Yarn
run: yarn install
- name: Setup Database
run: |
bin/rails db:create db:schema:load
bin/rails db:test:load_schema
- name: Prepare Code Climate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Run RSpec
run: bin/rspec
- name: Notify Code Climate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
deploy:
name: Deploy to Production
needs: [test]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: github-actions
known_hosts: '...'
config: |
host otvorenesudy.sk
IdentityFile ~/.ssh/github-actions
IdentitiesOnly yes
ForwardAgent yes
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }}
- name: Checkout Branch
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
bundler-cache: true
- name: Deploy
run: |
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/github-actions
bundle exec cap production deploy deploy:restart sidekiq:restart