Skip to content

Commit

Permalink
[config] 아티팩트 업로드, 다운로드 추가
Browse files Browse the repository at this point in the history
- 서버가 많아짐에 따라 3개의 인스턴스에 나누어 배포
- 변경이 있는 모듈만 다시 배포하도록 작성(임시로 모든 서버가 재배포되도록 구성)
  • Loading branch information
jcw1031 committed Aug 25, 2024
1 parent 5362fdc commit aefe783
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,31 @@ jobs:
run: chmod +x gradlew
- name: JAR 빌드
run: ./gradlew clean build
- name: 아티팩트 업로드
uses: actions/upload-artifact@v3
with:
name: jar-files
path: service/*/build/libs/*.jar

deploy-restaurant-exposure:
needs: [ changes, build ]
if: ${{ needs.changes.outputs.restaurant-exposure == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: JAR 파일 다운로드
uses: actions/download-artifact@v3
with:
name: jar-files
path: jars
- name: 가게노출 서비스 서버로 JAR 전송
env:
PRIVATE_KEY: ${{ secrets.DEV_EC2_SSH_KEY }}
HOST: ${{ secrets.DEV_EC2_HOST1 }}
USER: ${{ secrets.DEV_EC2_USER }}
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
echo "Current directory:"
pwd
echo "Contents of current directory:"
ls -R
echo "Contents of build directory:"
ls -R service/search-service/build/libs/
scp -o StrictHostKeyChecking=no -i private_key service/restaurant-exposure-service/build/libs/*.jar ${USER}@${HOST}:~/restaurant-exposure-service.jar
scp -o StrictHostKeyChecking=no -i private_key jars/restaurant-exposure-service-*.jar ${USER}@${HOST}:~/restaurant-exposure-service.jar
- name: 가게노출 서비스 실행
env:
PRIVATE_KEY: ${{ secrets.DEV_EC2_SSH_KEY }}
Expand All @@ -92,22 +94,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: JAR 파일 다운로드
uses: actions/download-artifact@v3
with:
name: jar-files
path: jars
- name: 검색 서비스 서버로 JAR 전송
env:
PRIVATE_KEY: ${{ secrets.DEV_EC2_SSH_KEY }}
HOST: ${{ secrets.DEV_EC2_HOST2 }}
USER: ${{ secrets.DEV_EC2_USER }}
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
echo "Current directory:"
pwd
echo "Contents of current directory:"
ls -R
echo "Contents of build directory:"
ls -R service/search-service/build/libs/
scp -o StrictHostKeyChecking=no -i private_key service/search-service/build/libs/*.jar ${USER}@${HOST}:~/search-service.jar
scp -o StrictHostKeyChecking=no -i private_key jars/search-service-*.jar ${USER}@${HOST}:~/search-service.jar
- name: 검색 서비스 실행
env:
PRIVATE_KEY: ${{ secrets.DEV_EC2_SSH_KEY }}
Expand All @@ -121,10 +120,15 @@ jobs:
deploy-other-services:
needs: [ changes, build ]
if: ${{ needs.changes.outputs.cache == 'true' || needs.changes.outputs.advertisement == 'true' || needs.changes.outputs.coupon == 'true' || needs.changes.outputs.delivery-time == 'true' || needs.changes.outputs.restaurant == 'true' }}
if: ${{ needs.changes.outputs.cache == 'false' || needs.changes.outputs.advertisement == 'true' || needs.changes.outputs.coupon == 'true' || needs.changes.outputs.delivery-time == 'true' || needs.changes.outputs.restaurant == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: JAR 파일 다운로드
uses: actions/download-artifact@v3
with:
name: jar-files
path: jars
- name: 기타 서비스 서버로 JAR 전송
env:
PRIVATE_KEY: ${{ secrets.DEV_EC2_SSH_KEY }}
Expand All @@ -133,19 +137,19 @@ jobs:
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
if [[ "${{ needs.changes.outputs.cache }}" == 'false' ]]; then
scp -o StrictHostKeyChecking=no -i private_key service/cache-service/build/libs/*.jar ${USER}@${HOST}:~/cache-service.jar
scp -o StrictHostKeyChecking=no -i private_key jars/cache-service-*.jar ${USER}@${HOST}:~/cache-service.jar
fi
if [[ "${{ needs.changes.outputs.advertisement }}" == 'false' ]]; then
scp -o StrictHostKeyChecking=no -i private_key service/advertisement-service/build/libs/*.jar ${USER}@${HOST}:~/advertisement-service.jar
scp -o StrictHostKeyChecking=no -i private_key jars/advertisement-service-*.jar ${USER}@${HOST}:~/advertisement-service.jar
fi
if [[ "${{ needs.changes.outputs.coupon }}" == 'false' ]]; then
scp -o StrictHostKeyChecking=no -i private_key service/coupon-service/build/libs/*.jar ${USER}@${HOST}:~/coupon-service.jar
scp -o StrictHostKeyChecking=no -i private_key jars/coupon-service-*.jar ${USER}@${HOST}:~/coupon-service.jar
fi
if [[ "${{ needs.changes.outputs.delivery-time }}" == 'false' ]]; then
scp -o StrictHostKeyChecking=no -i private_key service/delivery-time-service/build/libs/*.jar ${USER}@${HOST}:~/delivery-time-service.jar
scp -o StrictHostKeyChecking=no -i private_key jars/delivery-time-service-*.jar ${USER}@${HOST}:~/delivery-time-service.jar
fi
if [[ "${{ needs.changes.outputs.restaurant }}" == 'false' ]]; then
scp -o StrictHostKeyChecking=no -i private_key service/restaurant-service/build/libs/*.jar ${USER}@${HOST}:~/restaurant-service.jar
scp -o StrictHostKeyChecking=no -i private_key jars/restaurant-service-*.jar ${USER}@${HOST}:~/restaurant-service.jar
fi
- name: 기타 서비스들 실행
env:
Expand Down

0 comments on commit aefe783

Please sign in to comment.