[DEPLOY] 모니터링 구축 #6
This file contains hidden or 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 workflow on production | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| types: | |
| - closed | |
| jobs: | |
| deploy: | |
| if: github.event.pull_request.merged == true | |
| env: | |
| ENV_PATH: .env | |
| S3_BUCKET_DIR_NAME: production | |
| DEPLOYMENT_GROUP_NAME: production | |
| environment: production | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: ✅ Checkout branch | |
| uses: actions/checkout@v3 | |
| - name: 📦 Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: 🗂️ Make config folder | |
| run: mkdir -p config | |
| - name: 📦 Build JAR File | |
| run: ./gradlew clean build -x test | |
| - name: ⚙️ Create .env file | |
| run: | | |
| touch ${{ env.ENV_PATH }} | |
| echo DOMAIN_FIR=${{ secrets.DOMAIN_FIR }} >> ${{ env.ENV_PATH }} | |
| echo SOCKET_PORT_PROD=${{ secrets.SOCKET_PORT_PROD }} >> ${{ env.ENV_PATH }} | |
| - name: 📦 Zip project files | |
| run: zip -r ./$GITHUB_SHA.zip . | |
| - name: 🌎 Access to AWS | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ap-northeast-2 | |
| - name: 🚛 Upload to S3 | |
| run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ secrets.S3_BUCKET_NAME }}/${{ env.S3_BUCKET_DIR_NAME }}/$GITHUB_SHA.zip | |
| - name: 🚀 Deploy to EC2 with CodeDeploy | |
| run: aws deploy create-deployment | |
| --application-name woorizip-bank-codedeploy | |
| --deployment-config-name CodeDeployDefault.AllAtOnce | |
| --deployment-group-name ${{ env.DEPLOYMENT_GROUP_NAME }} | |
| --s3-location bucket=${{ secrets.S3_BUCKET_NAME }},bundleType=zip,key=${{ env.S3_BUCKET_DIR_NAME }}/$GITHUB_SHA.zip |