Merge pull request #71 from Mark-Twain-2025/develop #3
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 Client to EC2 | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Copy SSH key | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.EC2_KEY }}" > ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| - name: Add known hosts | |
| run: ssh-keyscan ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts | |
| - name: Deploy via SSH | |
| run: | | |
| ssh ec2-user@${{ secrets.EC2_HOST }} <<EOF | |
| cd ~/client | |
| git pull origin main | |
| npm install | |
| pm2 restart client || pm2 start 'npm run build && npm run start' --name client | |
| EOF |