From 3461ab630a73ad9c6d75a8546b452b42d27b9e68 Mon Sep 17 00:00:00 2001 From: sujalshrestha Date: Wed, 5 Feb 2025 20:39:50 +0545 Subject: [PATCH] add cd_prod for ssh redeploy --- .github/workflows/cd_prod.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/cd_prod.yml diff --git a/.github/workflows/cd_prod.yml b/.github/workflows/cd_prod.yml new file mode 100644 index 0000000..fa198cd --- /dev/null +++ b/.github/workflows/cd_prod.yml @@ -0,0 +1,31 @@ +name: Deploy to Production +on: + push: + branches: + - production + +jobs: + redeploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: executing remote ssh commands using ssh key + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + script: | + cd ~/0txt + # git reset --hard + # git clean -fd + git checkout production + git pull origin production + npm install + npm run lint + npm run build + pm2 stop 0txt-prod || true + pm2 start npm --name "0txt-prod" -- run start + pm2 save