From d38ad372e9b108c7bbb669e0ab4e968d46324e21 Mon Sep 17 00:00:00 2001 From: Todd Cooper Date: Wed, 13 Nov 2024 15:02:06 -0500 Subject: [PATCH] Create nodejs.yml --- .github/workflows/nodejs.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/nodejs.yml diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml new file mode 100644 index 0000000..cd16c48 --- /dev/null +++ b/.github/workflows/nodejs.yml @@ -0,0 +1,35 @@ +name: Node.js CI/CD on Amazon Linux + +on: + push: + branches: [ master ] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install dependencies + run: npm install + + - name: Deploy to AWS EC2 + uses: appleboy/scp-action@master + with: + host: ${{ secrets.REMOTE_HOST }} + username: ${{ secrets.REMOTE_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + source: "./" # This now correctly points to the current directory + target: "/var/www/your_project_directory" + + - name: Restart PM2 application + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.REMOTE_HOST }} + username: ${{ secrets.REMOTE_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + script: | + cd /var/www/your_project_directory + pm2 reload all # This command restarts your application +