Merge pull request #241 from tnpfldyd/BE-fix/server-api #16
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: BE-deploy | |
on: | |
push: | |
branches: | |
- "BE-develop" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: BE-develop | |
sparse-checkout: nestjs-BE | |
- name: Login to github Packages | |
run: echo ${{ secrets.PACKAGE_ACCESS_TOKEN }} | docker login ghcr.io -u ${{ secrets.PACKAGE_USERNAME }} --password-stdin | |
- name: Build and push Docker image | |
run: | | |
echo "SERVER_PORT=$SERVER_PORT" >> ./nestjs-BE/server/.env | |
echo "JWT_ACCESS_SECRET=$JWT_ACCESS_SECRET" >> ./nestjs-BE/server/.env | |
echo "JWT_REFRESH_SECRET=$JWT_REFRESH_SECRET" >> ./nestjs-BE/server/.env | |
echo "KAKAO_ADMIN_KEY=$KAKAO_ADMIN_KEY" >> ./nestjs-BE/server/.env | |
echo "MYSQL_DATABASE_URL=$MYSQL_DATABASE_URL" >> ./nestjs-BE/server/.env | |
echo "MONGODB_DATABASE_URL=$MONGODB_DATABASE_URL" >> ./nestjs-BE/server/.env | |
echo "MONGODB_DATABASE_URI=$MONGODB_DATABASE_URI" >> ./nestjs-BE/server/.env | |
echo "NCLOUD_ACCESS_KEY=$NCLOUD_ACCESS_KEY" >> ./nestjs-BE/server/.env | |
echo "NCLOUD_SECRET_KEY=$NCLOUD_SECRET_KEY" >> ./nestjs-BE/server/.env | |
echo "NCLOUD_REGION=$NCLOUD_REGION" >> ./nestjs-BE/server/.env | |
echo "STORAGE_URL=$STORAGE_URL" >> ./nestjs-BE/server/.env | |
echo "BASE_IMAGE_URL=$BASE_IMAGE_URL" >> ./nestjs-BE/server/.env | |
echo "BUCKET_NAME=$BUCKET_NAME" >> ./nestjs-BE/server/.env | |
echo "APP_ICON_URL=$APP_ICON_URL" >> ./nestjs-BE/server/.env | |
echo "CSV_FOLDER=$CSV_FOLDER" >> ./nestjs-BE/server/.env | |
docker build -t ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync ./nestjs-BE/server | |
docker push ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync:latest | |
env: | |
SERVER_PORT: ${{ secrets.CONTAINER_PORT }} | |
JWT_ACCESS_SECRET: ${{ secrets.JWT_ACCESS_SECRET }} | |
JWT_REFRESH_SECRET: ${{ secrets.JWT_REFRESH_SECRET }} | |
KAKAO_ADMIN_KEY: ${{ secrets.KAKAO_ADMIN_KEY }} | |
MYSQL_DATABASE_URL: ${{ secrets.MYSQL_DATABASE_URL }} | |
MONGODB_DATABASE_URL: ${{ secrets.MONGODB_DATABASE_URL }} | |
MONGODB_DATABASE_URI: ${{ secrets.MONGODB_DATABASE_URI }} | |
NCLOUD_ACCESS_KEY: ${{ secrets.NCLOUD_ACCESS_KEY }} | |
NCLOUD_SECRET_KEY: ${{ secrets.NCLOUD_SECRET_KEY }} | |
NCLOUD_REGION: ${{ secrets.NCLOUD_REGION }} | |
STORAGE_URL: ${{ secrets.STORAGE_URL }} | |
BASE_IMAGE_URL: ${{ secrets.BASE_IMAGE_URL }} | |
BUCKET_NAME: ${{ secrets.BUCKET_NAME }} | |
APP_ICON_URL: ${{ secrets.APP_ICON_URL }} | |
CSV_FOLDER: ${{ secrets.CSV_FOLDER }} | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Pull Docker image | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
port: ${{ secrets.REMOTE_PORT }} | |
username: ${{ secrets.REMOTE_USER }} | |
key: ${{ secrets.REMOTE_SSH_KEY }} | |
script: | | |
echo ${{ secrets.PACKAGE_ACCESS_TOKEN }} | docker login ghcr.io -u ${{ secrets.PACKAGE_USERNAME }} --password-stdin | |
docker pull ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync | |
docker stop mindsync_server || true | |
docker rm mindsync_server || true | |
docker run -d \ | |
--name mindsync_server \ | |
-p ${{ secrets.SERVER_PORT }}:${{ secrets.CONTAINER_PORT }} \ | |
-v temporary-volume:${{ secrets.CSV_FOLDER }} \ | |
ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync |