Merge pull request #115 from depromeet/feature/#9 #59
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: deploy-bbogak-dev-server | |
on: | |
push: | |
branches: main | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Build and Test | |
run: | | |
chmod +x gradlew | |
./gradlew build -x openapi3 | |
deploy: | |
runs-on: ubuntu-latest | |
needs: ci | |
steps: | |
- name: Deploy spring MainServer(main) | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
port: ${{ secrets.SERVER_PORT }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SERVER_KEY }} | |
script: | | |
cd ~/bbo-gak-server | |
git add . | |
git commit -m "temp commit" | |
git fetch origin main | |
git merge origin/main | |
git pull origin main | |
if [ $? -ne 0 ]; then # 병합 명령어의 종료 상태를 확인합니다. | |
echo "Merge conflict detected. Resolving by applying remote changes." | |
git checkout --theirs $(git diff --name-only --diff-filter=U) # 충돌이 발생한 파일에 원격 변경 사항을 적용합니다. | |
git add . # 충돌이 해결된 파일을 스테이징합니다. | |
git commit -m "Resolved merge conflicts by applying remote changes." # 커밋 메시지를 작성하여 충돌 해결을 커밋합니다. | |
else | |
echo "Merge successful, no conflicts detected." | |
fi | |
./gradlew clean build | |
./gradlew openapi3 | |
docker rm bbo-gak-server-back-1 --force | |
docker rmi bbo-gak-server-back | |
docker-compose -f docker-compose-dev.yml up --build -d |