Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] CICD 정비 #3

Merged
merged 10 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions .github/workflows/gradle.yml → .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle

on:
push:
branches: [ "main", "dev" ]
pull_request:
branches: [ "main", "dev" ]
branches: [ "dev" ]

permissions:
contents: read
Expand All @@ -27,6 +18,21 @@ jobs:
with:
java-version: '17'
distribution: 'temurin'

- name: make .env
run: |
touch ./.env
echo "${{ secrets.ENV }}" > ./.env

- name: SCP transfer
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.NCP_USERNAME }}
password: ${{ secrets.NCP_PASSWORD }}
port: ${{ secrets.NCP_PORT }}
source: ${{ secrets.SOURCE_PATH }}
target: ${{ secrets.DIST_PATH }}

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -44,14 +50,15 @@ jobs:
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }} # NCP 서버접속용 공인 IP
username: ${{ secrets.NCP_USERNAME }}
password: ${{ secrets.NCP_PASSWORD }}
port: ${{ secrets.NCP_PORT }} # port
# 도커 작업
script: |
host: ${{ secrets.HOST }} # NCP 서버접속용 공인 IP
username: ${{ secrets.NCP_USERNAME }} # instance user
password: ${{ secrets.NCP_PASSWORD }} # instance pw
port: ${{ secrets.NCP_PORT }} # port

script: | # docker compose deploy
cd /home/linker
docker-compose -f docker-compose.dev.yml down
docker pull ${{ secrets.DOCKER_USERNAME }}/linker:latest
docker-compose -f docker-compose.dev.yml up -d
docker-compose -f docker-compose.dev.yml up --build -d
docker rm $(docker ps --filter 'status=exited' -a -q)
docker image prune -a -f
2 changes: 2 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:
volumes:
- ${WRITABLE_DIR}/mysqldata:/var/lib/mysql
- ${DEPLOY_DIR}/init.sql:/docker-entrypoint-initdb.d/initdb.sql
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_PASSWORD}
ports:
- "3306:3306"
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
2 changes: 2 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ services:
volumes:
- ${WRITABLE_DIR}/mysqldata:/var/lib/mysql
- ${DEPLOY_DIR}/init.sql:/docker-entrypoint-initdb.d/initdb.sql
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_PASSWORD}
ports:
- "3306:3306"
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci