update for workflow run #112
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: Build and Deploy to Prod | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install Dependencies | |
| run: bun install | |
| - name: Run Build | |
| run: bun run build | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Setup SSH | |
| uses: webfactory/ssh-agent@v0.5.4 | |
| with: | |
| ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| - name: Add EC2 host to known hosts | |
| run: ssh-keyscan -H ${{ secrets.EC2_PUBLIC_IP }} >> ~/.ssh/known_hosts | |
| - name: Create symlinks and deploy to EC2 | |
| run: | | |
| ssh ubuntu@${{ secrets.EC2_PUBLIC_IP }} -t " | |
| set -e | |
| echo 'Updating code' | |
| cd paircode.live | |
| git pull origin main | |
| echo 'Stopping old containers' | |
| sudo docker stop paircode-be || true | |
| sudo docker rm paircode-be || true | |
| echo 'Deleting the image' | |
| sudo docker rmi paircode-be-img || true | |
| echo 'Building image' | |
| sudo docker build -t paircode-be-img -f apps/server/Dockerfile . | |
| echo 'Running container' | |
| sudo docker run -d \ | |
| --net=host \ | |
| --name paircode-be \ | |
| --env-file /home/ubuntu/paircode.live/.env.server \ | |
| paircode-be-img:latest | |
| " |