Chore: develop 브랜치로 머지되면 트리거 되도록 CD 변경 #8
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: Backend CD | |
on: | |
push: | |
branches: [ "develop" ] | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set env | |
run: | | |
mkdir envs | |
echo "DB_HOST=${{ secrets.DB_HOST }}" >> envs/prod.env | |
echo "DB_PORT=${{ secrets.DB_PORT }}" >> envs/prod.env | |
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> envs/prod.env | |
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> envs/prod.env | |
echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" >> envs/prod.env | |
- name: Build docker image | |
run: docker build . -t rankin:latest | |
deploy: | |
needs: build | |
runs-on: self-hosted | |
steps: | |
- name: Stop docker | |
run: | | |
docker stop rankin && docker rm rankin | |
- name: Run docker | |
if: always() | |
run: | | |
docker run --name rankin -d -p 3000:3000 -v /var/rankin/logs:/app/logs rankin:latest | |