Skip to content

Commit

Permalink
Merge branch 'server/release/#0.5.5' into server/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
yangdongsuk authored Dec 14, 2023
2 parents d10f5fd + 94ee4c9 commit f62b10a
Show file tree
Hide file tree
Showing 468 changed files with 28,662 additions and 108 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/client-deploy-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Transfer App Directory via using scp command on Push or Merge to Server

on:
push:
branches:
- 'client/release/*'
pull_request:
types: [closed]
branches:
- 'client/release/*'

jobs:
transfer-app:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Add SSH key to known_hosts
run: |
echo "${{ secrets.SSH_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Transfer app directory to the server
run: |
scp -r app root@223.130.130.221:/var/www/html/
116 changes: 116 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: CI/CD Docker

on:
pull_request:
types: [closed]
branches:
- 'server/release/*'

env:
DOCKER_IMAGE: ghcr.io/${{ github.actor }}/nest-openlist-deploy
VERSION: ${{ github.sha }}
NAME: go_cicd

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v2
# .env 파일 생성
- name: Generate .env file
run: |
cat << EOF > ./server/.env
JWT_SECRET=${{ secrets.JWT_SECRET }}
ACCESS_TOKEN_EXPIRES=${{ secrets.ACCESS_TOKEN_EXPIRES }}
REFRESH_TOKEN_EXPIRES=${{ secrets.REFRESH_TOKEN_EXPIRES }}
HASH_ROUNDS=${{ secrets.HASH_ROUNDS }}
PROTOCOL=${{ secrets.PROTOCOL }}
HOST=${{ secrets.HOST }}
DB_HOST=${{ secrets.DB_HOST }}
DB_PORT=${{ secrets.DB_PORT }}
DB_USERNAME=${{ secrets.DB_USERNAME }}
DB_PASSWORD=${{ secrets.DB_PASSWORD }}
DB_DATABASE=${{ secrets.DB_DATABASE }}
SUB=${{ secrets.SUB }}
ALG=${{ secrets.ALG }}
KID=${{ secrets.KID }}
ISS=${{ secrets.ISS }}
AUTHKEY=${{ secrets.AUTHKEY }}
X_NCP_CLOVASTUDIO_API_KEY=${{ secrets.X_NCP_CLOVASTUDIO_API_KEY }}
X_NCP_APIGW_API_KEY=${{ secrets.X_NCP_APIGW_API_KEY }}
X_NCP_CLOVASTUDIO_REQUEST_ID=${{ secrets.X_NCP_CLOVASTUDIO_REQUEST_ID }}
REDIS_URL=${{ secrets.REDIS_URL }}
REDIS_USERNAME=${{ secrets.REDIS_USERNAME }}
REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }}
ADMIN_EMAIL=${{ secrets.ADMIN_EMAIL }}
ADMIN_PASSWORD=${{ secrets.ADMIN_PASSWORD }}
EOF
- name: Generate .p8 file
run: |
cat << EOF > ./server/.p8
${{ secrets.P8 }}
EOF
- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ env.VERSION }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./server
file: ./server/Dockerfile
push: true
tags: ${{ env.DOCKER_IMAGE }}:latest

# 배포 Job - 서버 1
deploy-server1:
needs: build
name: Deploy to Server 1
runs-on: [ self-hosted, label-server1 ]
steps:
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Docker run (Server 1)
run: |
docker stop go_cicd1 || true
docker rm go_cicd1 || true
docker pull ${{ env.DOCKER_IMAGE }}:latest
docker run -d -p 3000:3000 --name go_cicd1 --restart always ${{ env.DOCKER_IMAGE }}:latest
# 배포 Job - 서버 2
deploy-server2:
needs: build
name: Deploy to Server 2
runs-on: [ self-hosted, label-server2 ]
steps:
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Docker run (Server 2)
run: |
docker stop go_cicd2 || true
docker rm go_cicd2 || true
docker pull ${{ env.DOCKER_IMAGE }}:latest
docker run -d -p 3000:3000 --name go_cicd2 --restart always ${{ env.DOCKER_IMAGE }}:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/dataSources.local.xml

/.idea

Loading

0 comments on commit f62b10a

Please sign in to comment.