[Deploy] PR preview url 생성 workflows 구축 (#174) #2
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: express-deployment | |
| on: | |
| push: | |
| branches: [develop] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Git Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.12.1 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20.x" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Configure SSH | |
| uses: webfactory/ssh-agent@v0.8.0 | |
| with: | |
| ssh-private-key: ${{ secrets.AWS_PRIVATE_KEY }} | |
| - name: Deploy to EC2 | |
| env: | |
| AWS_REGION: ${{ secrets.AWS_REGION }} | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| AWS_EC2_HOST: ${{ secrets.AWS_EC2_HOST }} | |
| AWS_EC2_USER: ${{ secrets.AWS_EC2_USER }} | |
| run: | | |
| ssh -o StrictHostKeyChecking=no "$AWS_EC2_USER@$AWS_EC2_HOST" << 'EOF' | |
| cd /home/ubuntu/build/codeit-resources | |
| git pull origin develop | |
| pnpm install --frozen-lockfile | |
| pnpm --filter=api build | |
| pm2 restart codeit-server | |
| EOF |