ci: test pm2 #25
This file contains 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@v2 | |
- name: Deploy to EC2 | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
EC2_HOST: ${{ secrets.EC2_HOST }} | |
EC2_USER: ${{ secrets.EC2_USER }} | |
EC2_KEY: ${{ secrets.EC2_KEY }} | |
run: | | |
echo "${{ secrets.EC2_KEY }}" | base64 --decode > ec2-key.pem | |
chmod 400 ec2-key.pem | |
echo "Trying to connect to ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} with key ec2-key.pem" | |
ssh -i ec2-key.pem -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF' | |
cd /home/${{ secrets.EC2_USER }}/stocky-server | |
npm install | |
# pm2 restart all || pm2 start src/index.ts --name stocky-server | |
pm2 restart all || pm2 start ecosystem.config.cjs --only stocky-server | |
EOF |