[deploy] 2.0.1 deploy #197
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: 🚀 YELL:O Deploy | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: 👉 JDK 17 zulu 버전을 세팅합니다. | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'zulu' | |
cache: gradle | |
- name: 🐘 Gradle에 권한을 부여합니다. | |
run: chmod +x gradlew | |
shell: bash | |
## 시크릿 키 설정 | |
- name: 🔐 application.yml 등 환경 변수를 세팅합니다. | |
run: | | |
cd ./src/main/resources | |
touch ./application.yml | |
echo "$APPLICATION" > ./application.yml | |
touch ./firebase_key.json | |
echo "$FIREBASE_JSON" > ./firebase_key.json | |
sed -i 's/#/"/g' ./firebase_key.json | |
touch ./google_client_secret.json | |
echo "$GOOGLE_CLIENT_SECRET" > ./google_client_secret.json | |
sed -i 's/#/"/g' ./google_client_secret.json | |
touch ./apple_client_secret.json | |
echo "$APPLE_CLIENT_SECRET" > ./apple_client_secret.json | |
sed -i 's/#/"/g' ./apple_client_secret.json | |
env: | |
APPLICATION: ${{ secrets.APPLICATION }} | |
FIREBASE_JSON: ${{ secrets.FIREBASE_JSON }} | |
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} | |
APPLE_CLIENT_SECRET: ${{ secrets.APPLE_CLIENT_SECRET }} | |
shell: bash | |
- name: 🐘 Gradle로 빌드 실행 | |
run: ./gradlew build | |
- name: 📦 배포를 진행하기 위한 .zip 파일을 생성합니다. | |
run: | | |
mkdir deploy | |
cp ./docker/docker-compose.blue.yml ./deploy/ | |
cp ./docker/docker-compose.green.yml ./deploy/ | |
cp ./appspec.yml ./deploy/ | |
cp ./docker/Dockerfile ./deploy/ | |
cp ./scripts/*.sh ./deploy/ | |
cp ./build/libs/*.jar ./deploy/ | |
zip -r -qq -j ./yello-build.zip ./deploy | |
shell: bash | |
- name: ⏳ AWS에 연결을 진행합니다. | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: 🪣 배포를 위해 S3에 프로젝트를 업로드합니다. | |
run: | | |
aws s3 cp \ | |
--region ap-northeast-2 \ | |
./yello-build.zip s3://yello-server-bucket | |
- name: 📡 CodeDeploy에 배포를 요청합니다. | |
run: aws deploy create-deployment --application-name yello-server-deploy | |
--deployment-config-name CodeDeployDefault.OneAtATime | |
--deployment-group-name yello-app | |
--s3-location bucket=yello-server-bucket,bundleType=zip,key=yello-build.zip | |
- name: 💡 배포 상태를 Slack을 통해 전송합니다. | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_CHANNEL: general | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_ICON: https://github.com/rtCamp.png?size=48 | |
SLACK_MESSAGE: 배포에 ${{ job.status }} 했습니다. | |
SLACK_TITLE: 🚀 YELL:O 배포 결과 🚀 | |
SLACK_USERNAME: Notification-Bot | |
SLACK_WEBHOOK: ${{ secrets.SLACK_URL }} | |
if: always() |