Revise comments in deploy.yml for deployment steps #4
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 | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| # 1. 폴더가 없으면 토큰 주소로 클론 | |
| if [ ! -d "~/backend" ]; then | |
| git clone https://${{ secrets.MY_GITHUB_TOKEN }}@github.com/Amore-Innovation/backend.git ~/backend | |
| fi | |
| # 2. 폴더 이동 및 토큰 권한 갱신 | |
| cd ~/backend | |
| git remote set-url origin https://${{ secrets.MY_GITHUB_TOKEN }}@github.com/Amore-Innovation/backend.git | |
| # 3. 최신 코드 반영 및 도커 실행 | |
| git pull origin main | |
| docker-compose up -d --build |