Skip to content

Update integration.yml #16

Update integration.yml

Update integration.yml #16

Workflow file for this run

name: Integrations
on:
push:
branches:
- main # or your default branch
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout code
- name: Checkout code
uses: actions/checkout@v2
# Step 2: Set up the environment
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x' # specify your Node.js version
# Step 3: Install dependencies
- name: Install dependencies
run: npm i
# step 4 Build
- name: Run build
run: npm run build
# step 5
- name: Run TEST
run: npm run test
deploy:
runs-on: ubuntu-latest
needs: build # ensures the deploy job runs after the build job
steps:
# Step 1: Checkout code
- name: Checkout code
uses: actions/checkout@v2
# Step 2: Set up Node.js (again for deployment environment)
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.x'
# Step 3: Install dependencies (again in the deployment environment)
- name: Install dependencies
run: npm install
# Step 4: Deploy to the server via SSH
- name: Deploy to Server
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} << 'EOF'
cd /next-js-app/app
git pull origin main
npm install
npm run build # if you have a build step, otherwise skip
pm2 restart all # or your preferred process manager
EOF
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}