Skip to content

v4.0.15

v4.0.15 #33

Workflow file for this run

name: CD-dev
on:
release:
types: [ "published" ]
jobs:
deploy-ci:
runs-on: ubuntu-latest
steps:
- name: Checkout Latest Repo
uses: actions/checkout@v3
# 최신 저장소에서 체크아웃
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
# 자바 버전을 JDK 17로 설정
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_DEV }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_DEV }}
aws-region: ap-northeast-2
# AWS 자격 증명 설정
- name: Set FCM JSON File Path
run: |
echo "FCM_JSON_PATH=smeem-output-notification/src/main/resources/firebase-config/smeem_fcm_dev.json" >> $GITHUB_ENV
# FCM JSON 파일 위치 경로 설정
- name: Create FCM JSON File from AWS
run: aws s3 cp --region ap-northeast-2 ${{ secrets.AWS_S3_FCM_JSON_URI_DEV }} ${{ env.FCM_JSON_PATH }}
# FCM JSON 파일 복사
- name: Grant execute permission for gradlew
run: chmod +x gradlew
shell: bash
# gradlew 파일에 실행 권한 부여
- name: Build with Gradle
run: ./gradlew clean build -x test
shell: bash
# 그래들로 빌드
- name: Set Docker
uses: docker/[email protected]
# 도커 설정
- name: Login Docker
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_LOGIN_USERNAME_DEV }}
password: ${{ secrets.DOCKERHUB_LOGIN_ACCESSTOKEN_DEV }}
# 도커에 로그인
- name: Docker Build
run: |
docker build --platform linux/amd64 -t smeemdev/smeem-dev:latest -f Dockerfile-dev .
docker push smeemdev/smeem-dev:latest
deploy-cd:
needs: deploy-ci
runs-on: ubuntu-latest
# deploy-ci 이후 작업 실행
steps:
- name: Connect to EC2 and Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.RELEASE_SERVER_IP_DEV }}
username: ${{ secrets.RELEASE_SERVER_USER_DEV }}
key: ${{ secrets.RELEASE_SERVER_KEY_DEV }}
script: |
cd ~
# deploy.sh 파일 다운로드
wget https://raw.githubusercontent.com/Team-Smeme/Smeme-server-renewal/develop/script/deploy.sh -O deploy.sh
chmod +x deploy.sh
# 기존 .env 파일 삭제 및 새로 생성
rm -f .env # 기존 .env 파일을 삭제합니다.
# .env 파일 새로 생성
echo "REGISTRY_URL=${{ secrets.REGISTRY_URL_DEV }}" >> .env
echo "IMAGE_NAME=${{ secrets.IMAGE_NAME_DEV }}" >> .env
echo "SECRET_MANAGER_TOKEN=${{ secrets.SECRET_MANAGER_TOKEN }}" >> .env
echo "SECRET_MANAGER_WORKSPACE_ID=${{ secrets.SECRET_MANAGER_WORKSPACE_ID }}" >> .env
# 배포 스크립트 실행
sudo ./deploy.sh