#576 [feat] flow 변경 #2
Workflow file for this run
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: PROD-CD | |
on: [ "push" ] | |
jobs: | |
production-deploy-ci: | |
runs-on: ubuntu-22.04 | |
env: | |
working-directory: . | |
steps: | |
- name: 체크아웃 | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
- name: application.yaml 생성 | |
run: | | |
cd ./module-api/src/main/resources | |
touch ./application.yml | |
echo "${{ secrets.NEW_PROD_SETTING }}" > ./application.yml | |
cat ./application.yml | |
working-directory: ${{ env.working-directory }} | |
- name: 빌드 | |
run: | | |
chmod +x gradlew | |
./gradlew build -x test | |
working-directory: ${{ env.working-directory }} | |
shell: bash | |
- name: docker build 환경 설정 | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker Hub 로그인 | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_SECRET }} | |
- name: Docker 이미지 빌드 및 푸시 | |
run: | | |
docker build --platform linux/amd64 -t mile1217/mile-server . | |
docker push mile1217/mile-server | |
working-directory: ${{ env.working-directory }} | |
production-deploy-cd: | |
needs: production-deploy-ci | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: deploy run | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.NEW_PROD_IP }} | |
username: ${{ secrets.NEW_PROD_USER }} | |
key: ${{ secrets.NEW_PROD_SSH }} | |
script: | | |
cd ~ | |
if docker ps | grep -q redis && docker ps | grep -q nginx; then | |
docker-compose pull app | |
docker-compose up -d --no-deps app | |
else | |
echo "all service is not running" | |
docker-compose down | |
docker-compose pull | |
docker-compose up -d --build |