Repository navigation
[merge] 캘린더 연동 시 회원 탈퇴 에러수정 배포 환경에 반영 #39
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: [deploy] | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. 코드 체크아웃 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 2. Docker Buildx 설정 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # 3. ghcr.io 로그인 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # 4. Docker 이미지 빌드 + push | |
| - name: Build and Push Docker Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64 | |
| tags: | | |
| ghcr.io/team-timo/timo-server:latest | |
| ghcr.io/team-timo/timo-server:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # 5. 배포 파일들을 EC2로 복사 (신규) | |
| - name: Copy deploy files to EC2 | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| source: "deploy/docker-compose.prod.yml,deploy/deploy.sh,deploy/prometheus/prometheus.yml,deploy/grafana/provisioning/datasources/datasource.yml" | |
| target: "~/timo-deploy/" | |
| strip_components: 1 | |
| # 6. EC2에 SSH 접속해서 Blue/Green 배포 실행 | |
| - name: Deploy to EC2 (Blue/Green) | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| echo "${{ secrets.GHCR_TOKEN }}" | sudo docker login ghcr.io -u "${{ secrets.GHCR_USERNAME }}" --password-stdin | |
| cd ~/timo-deploy | |
| chmod +x deploy.sh | |
| bash deploy.sh |