feat: CommonResponse 개선 및 컨트롤러 응답 리팩토링 #26
Workflow file for this run
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 to EC2 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - feat/internal-server-api | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/auth-server:latest | |
| ${{ secrets.DOCKERHUB_USERNAME }}/auth-server:${{ github.sha }} | |
| deploy: | |
| needs: build-and-push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup SSH | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.EC2_KEY }}" > ~/.ssh/ec2_key.pem | |
| chmod 600 ~/.ssh/ec2_key.pem | |
| - name: Prepare env file | |
| env: | |
| ENV_FILE_CONTENT: ${{ secrets.ENV_FILE }} | |
| run: | | |
| echo "$ENV_FILE_CONTENT" > auth-be.env | |
| - name: Ensure /env on EC2 | |
| run: | | |
| ssh -o StrictHostKeyChecking=no -i ~/.ssh/ec2_key.pem ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} \ | |
| "sudo mkdir -p /env && sudo chown ${{ secrets.EC2_USER }}:${{ secrets.EC2_USER }} /env" | |
| - name: Copy env file to EC2 | |
| run: | | |
| scp -o StrictHostKeyChecking=no -i ~/.ssh/ec2_key.pem auth-be.env ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:/env/auth-be.env | |
| - name: Deploy container on EC2 | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
| run: | | |
| ssh -o StrictHostKeyChecking=no -i ~/.ssh/ec2_key.pem ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} " \ | |
| echo \"$DOCKERHUB_TOKEN\" | docker login -u \"$DOCKERHUB_USERNAME\" --password-stdin 2>/dev/null || true && \ | |
| docker stop auth-be 2>/dev/null || true && \ | |
| docker rm auth-be 2>/dev/null || true && \ | |
| docker pull $DOCKERHUB_USERNAME/auth-server:latest && \ | |
| docker run -d --restart unless-stopped --name auth-be -p 9000:9000 --env-file /env/auth-be.env $DOCKERHUB_USERNAME/auth-server:latest \ | |
| " |