Adjust check-in start time for seminar attendance #119
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 Devtalk Project | |
| on: | |
| push: | |
| branches: | |
| - main | |
| env: | |
| SPRING_REPOSITORY: devtalk-server-ecr | |
| NGINX_REPOSITORY: devtalk-nginx-ecr | |
| IMAGE_TAG: latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Build Spring Boot Jar with prod profile | |
| run: | | |
| SPRING_PROFILES_ACTIVE=prod ./gradlew clean build -x test | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_GITHUB_ACTION_ROLE_ARN }} | |
| aws-region: ap-northeast-2 | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Build and Push Spring Image | |
| env: | |
| REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| run: | | |
| docker build -t $REGISTRY/${{ env.SPRING_REPOSITORY }}:${{ env.IMAGE_TAG }} . | |
| docker push $REGISTRY/${{ env.SPRING_REPOSITORY }}:${{ env.IMAGE_TAG }} | |
| - name: Build and Push Nginx Image | |
| env: | |
| REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| run: | | |
| cd nginx | |
| docker build -t $REGISTRY/${{ env.NGINX_REPOSITORY }}:${{ env.IMAGE_TAG }} . | |
| docker push $REGISTRY/${{ env.NGINX_REPOSITORY }}:${{ env.IMAGE_TAG }} | |
| - name: Copy docker-compose file to server | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.DEPLOY_SERVER_HOST }} | |
| username: ${{ secrets.DEPLOY_SERVER_USER }} | |
| key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }} | |
| port: ${{ secrets.DEPLOY_SERVER_PORT }} | |
| source: "docker-compose-prod.yml" | |
| target: "/home/ubuntu/Devtalk-Server-Application" | |
| - name: Deploy to Server | |
| uses: appleboy/ssh-action@master | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_PASSWORD: ${{ steps.login-ecr.outputs.docker_password_061391278365_dkr_ecr_ap_northeast_2_amazonaws_com }} | |
| with: | |
| host: ${{ secrets.DEPLOY_SERVER_HOST }} | |
| username: ${{ secrets.DEPLOY_SERVER_USER }} | |
| key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }} | |
| port: ${{ secrets.DEPLOY_SERVER_PORT }} | |
| envs: ECR_REGISTRY,ECR_PASSWORD,SPRING_REPOSITORY,NGINX_REPOSITORY,IMAGE_TAG # ② EC2로 전달 | |
| script: | | |
| echo "Using Registry: $ECR_REGISTRY" | |
| echo "$ECR_PASSWORD" | docker login --username AWS --password-stdin "$ECR_REGISTRY" | |
| cd /home/ubuntu/Devtalk-Server-Application | |
| docker-compose -f docker-compose-prod.yml down --rmi all -v --remove-orphans | |
| docker-compose -f docker-compose-prod.yml pull | |
| docker-compose -f docker-compose-prod.yml up -d |