diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 386741c..057b325 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Deploy to Server +name: Check and Deploy to Server on: push: @@ -6,21 +6,39 @@ on: - master jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "20" + + - name: Install dependencies + run: npm install + + - name: Run build + run: npm run build + deploy: runs-on: ubuntu-latest + needs: build steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install SSH and SCP - run: sudo apt-get update && sudo apt-get install -y openssh-client + run: sudo apt-get update && sudo apt-get install -y openssh-client sshpass - name: Copy files via SCP env: SSHPASS: ${{ secrets.ROOT_SSH_PASSWORD }} run: | - sudo apt-get install -y sshpass sshpass -e scp -o StrictHostKeyChecking=no -r ./* root@${{ secrets.SERVER_IP }}:/home/ppl_site - name: Execute remote commands @@ -29,6 +47,7 @@ jobs: run: | sshpass -e ssh -o StrictHostKeyChecking=no root@${{ secrets.SERVER_IP }} << 'EOF' cd /home/ppl_site + npm install npm run build systemctl restart ppl_site EOF