[HOTFIX] FE 연동 과정에서 발생한 에러 해결 #77
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: database-deploy | |
on: | |
pull_request: | |
types: [closed] | |
branches: | |
- development | |
jobs: | |
pull-n-run-docker-compose: | |
if: startsWith(github.event.pull_request.head.ref, 'database/') | |
name: Deploy MySQL Container with Docker Compose | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Create .database.env file for remote server | |
run: | | |
echo "MYSQL_ROOT_PASSWORD=${{ secrets.MYSQL_ROOT_PASSWORD }}" >> .database.env | |
echo "MYSQL_USER=${{ secrets.MYSQL_USER }}" >> .database.env | |
echo "MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }}" >> .database.env | |
- name: Copy docker-compose file to remote server | |
uses: garygrossgarten/github-action-scp@release | |
with: | |
local: ./docker-compose-db.yaml | |
remote: apps/docker-compose-db.yaml | |
host: ${{ secrets.NCP_SERVER_HOST }} | |
username: ${{ secrets.NCP_SERVER_USERNAME }} | |
password: ${{ secrets.NCP_SERVER_PASSWORD }} | |
- name: Copy .env file to remote server | |
uses: garygrossgarten/github-action-scp@release | |
with: | |
local: ./.database.env | |
remote: apps/.database.env | |
host: ${{ secrets.NCP_SERVER_HOST }} | |
username: ${{ secrets.NCP_SERVER_USERNAME }} | |
password: ${{ secrets.NCP_SERVER_PASSWORD }} | |
- name: Copy MySQL init scripts to remote server | |
uses: garygrossgarten/github-action-scp@release | |
with: | |
local: ./infra/mysql-init/ | |
remote: apps/.infra/mysql-init/ | |
host: ${{ secrets.NCP_SERVER_HOST }} | |
username: ${{ secrets.NCP_SERVER_USERNAME }} | |
password: ${{ secrets.NCP_SERVER_PASSWORD }} | |
- name: Access remote server via SSH and run docker-compose | |
uses: appleboy/ssh-action@master | |
env: | |
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }} | |
MYSQL_USER: ${{ secrets.MYSQL_USER }} | |
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} | |
with: | |
host: ${{ secrets.NCP_SERVER_HOST }} | |
username: ${{ secrets.NCP_SERVER_USERNAME }} | |
password: ${{ secrets.NCP_SERVER_PASSWORD }} | |
port: 22 | |
script: | | |
docker-compose -f apps/docker-compose-db.yaml down | |
docker-compose -f apps/docker-compose-db.yaml pull | |
docker-compose -f apps/docker-compose-db.yaml up -d --remove-orphans |