-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (35 loc) · 1.25 KB
/
deploy.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
name: Deploy to Production
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.3 # 使用するRubyのバージョンを指定
bundler-cache: true # Bundlerのキャッシュを有効に
- name: Install dependencies
run: |
gem install bundler
bundle install
- name: Run database migrations
env:
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
run: |
bundle exec rails db:migrate RAILS_ENV=production
- name: Deploy to Server
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
USER: ${{ secrets.SSH_USER }}
HOST: ${{ secrets.SSH_HOST }}
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
run: |
echo "$SSH_PRIVATE_KEY" > private_key.pem
chmod 600 private_key.pem
ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST "cd /home/ubuntu/www/book_log_list && git pull origin main && bundle install && RAILS_ENV=production bundle exec rake db:migrate && puma -C config/puma.rb -e production"