Skip to content

Merge pull request #63 from f-lab-edu/feature/62-article-seeder #53

Merge pull request #63 from f-lab-edu/feature/62-article-seeder

Merge pull request #63 from f-lab-edu/feature/62-article-seeder #53

Workflow file for this run

name: auto deploy
on:
push:
branches:
- develop
jobs:
push_to_registry:
name: Push to ncp container registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to NCP Container Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.NCP_CONTAINER_REGISTRY }}
username: ${{ secrets.NCP_ACCESS_KEY }}
password: ${{ secrets.NCP_SECRET_KEY }}
- name: build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/backend:latest
cache-from: type=registry,ref=${{ secrets.NCP_CONTAINER_REGISTRY }}/prv-backend:latest
cache-to: type=inline
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GIT_TOKEN }}
pull_from_registry:
name: Connect server ssh and pull from container registry
needs: push_to_registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Copy docker-compose file to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEV_HOST }}
username: ${{ secrets.DEV_USERNAME }}
password: ${{ secrets.DEV_PASSWORD }}
port: ${{ secrets.DEV_PORT }}
source: "docker-compose.yml"
target: "~/"
- name: connect ssh
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEV_HOST }}
username: ${{ secrets.DEV_USERNAME }}
password: ${{ secrets.DEV_PASSWORD }}
port: ${{ secrets.DEV_PORT }}
script: |
echo "DB_TYPE=${{ secrets.DB_TYPE }}" > .env
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env
echo "DB_PORT=${{ secrets.DB_PORT }}" >> .env
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> .env
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env
echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" >> .env
echo "DB_SYNCHRONIZE=${{ secrets.DB_SYNCHRONIZE }}" >> .env
echo "JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }}" >> .env
echo "MAIL_HOST=${{ secrets.MAIL_HOST }}" >> .env
echo "MAIL_PORT=${{ secrets.MAIL_PORT }}" >> .env
echo "MAIL_USER=${{ secrets.MAIL_USER }}" >> .env
echo "MAIL_PWD=${{ secrets.MAIL_PWD }}" >> .env
echo "API_BASE_URL=${{ secrets.API_BASE_URL }}" >> .env
echo "SERVER_PORT=${{ secrets.SERVER_PORT }}" >> .env
echo "NCP_CONTAINER_REGISTRY=${{ secrets.NCP_CONTAINER_REGISTRY }}" >> .env
echo "BACKEND_OUTBOUND_PORT=${{ secrets.BACKEND_OUTBOUND_PORT }}" >> .env
echo "BACKEND_INBOUND_PORT=${{ secrets.BACKEND_INBOUND_PORT }}" >> .env
echo "MYSQL_OUTBOUND_PORT=${{ secrets.MYSQL_OUTBOUND_PORT }}" >> .env
echo "MYSQL_INBOUND_PORT=${{ secrets.MYSQL_INBOUND_PORT }}" >> .env
echo "MYSQL_ROOT_PASSWORD=${{ secrets.MYSQL_ROOT_PASSWORD }}" >> .env
docker-compose down
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/backend:latest
docker-compose up -d
docker image prune -f