-
Notifications
You must be signed in to change notification settings - Fork 3
42 lines (40 loc) · 1.77 KB
/
deploy_demo_site.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 demo site
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create ssh config
env:
SSH_USER: ${{ secrets.DEMO_SITE_SSH_USER }}
SSH_HOSTNAME: ${{ secrets.DEMO_SITE_SSH_HOSTNAME }}
SSH_PRIVATE_KEY: ${{ secrets.DEMO_SITE_SSH_PRIVATE_KEY }}
SSH_KNOWN_HOSTS: ${{ secrets.DEMO_SITE_SSH_KNOWN_HOSTS }}
run: |
mkdir ~/.ssh
echo "${SSH_PRIVATE_KEY}" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
echo "${SSH_KNOWN_HOSTS}" > ~/.ssh/known_hosts && chmod 600 ~/.ssh/known_hosts
cat > ~/.ssh/config <<EOF
Host production
HostName ${SSH_HOSTNAME}
User ${SSH_USER}
EOF
- name: Create docker context
run: |
docker context create --docker host=ssh://production production
docker context use production
- name: Deploy to host
env:
COMPOSE_PROJECT_NAME: ytdlor_demo_site
SECRET_KEY_BASE: ${{ secrets.DEMO_SITE_SECRET_KEY_BASE }}
YTDLOR_WEB_PORT: 8001
run: |
docker compose -f docker-compose.yml -f docker-compose-production.yml -f docker-compose-demo-site.yml build
#docker compose -f docker-compose.yml -f docker-compose-production.yml -f docker-compose-demo-site.yml down
# ssh経由のcontextで docker compose down がうまく動かない問題のワークアラウンド
ssh production -- docker compose -p "${COMPOSE_PROJECT_NAME}" down
docker compose -f docker-compose.yml -f docker-compose-production.yml -f docker-compose-demo-site.yml run --rm web rails db:migrate
docker compose -f docker-compose.yml -f docker-compose-production.yml -f docker-compose-demo-site.yml up -d --remove-orphans