π [Release] μλ‘μ΄ λλ©μΈ μ¬λ°°ν¬ (#635) #24
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: Continuous Deployment | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push backend Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./backend/Dockerfile | |
platforms: linux/amd64, linux/arm64/v8 | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/ghostserver:latest | |
- name: Build and push frontend Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./frontend/Dockerfile | |
platforms: linux/amd64,linux/arm64/v8 | |
build-args: | | |
VITE_BASE_URL=${{ secrets.VITE_BASE_URL }} | |
VITE_API_URL=${{ secrets.VITE_BASE_URL }}/api/v1 | |
VITE_ASSET_URL=${{ secrets.VITE_BASE_URL }} | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest | |
deploy-to-ec2: | |
runs-on: ubuntu-latest | |
needs: build-and-push | |
steps: | |
- name: Deploy to Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USER }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
envs: GITHUB_SHA | |
script: | | |
sudo docker ps | |
sudo docker compose -f ~/docker-compose.yml down && \ | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ghostserver:latest && \ | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest && \ | |
sudo docker compose -f ~/docker-compose.yml up -d | |
sudo docker image prune -f |