Skip to content

certs added

certs added #21

Workflow file for this run

name: Deployment
on:
push:
branches:
- main
jobs:
validate:
runs-on: ubuntu-latest
permissions: # Add permissions for validate job
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Set file permissions # Add this step
run: |
sudo chown -R $USER:$USER .
sudo chmod -R 755 .
- name: Run lint checks
run: npm run lint
# Add test step if you have tests
# - name: Run tests
# run: npm test
deploy:
needs: validate
runs-on: ubuntu-latest
permissions: # Add permissions for deploy job
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2 # Needed for package.json diff check
- name: Check for package file changes
id: check_changes
run: |
if git diff --name-only HEAD^ HEAD | grep -q "package.*\.json"; then
echo "package_changes=true" >> $GITHUB_OUTPUT
else
echo "package_changes=false" >> $GITHUB_OUTPUT
fi
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_EC2_HOST }}
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
export PATH="$HOME/.nvm/versions/node/v22.13.1/bin:$PATH"
cd agentic-placeholder-be/
sudo chown -R ubuntu:ubuntu .
sudo chmod -R 755 .
git fetch origin main
git reset --hard origin/main
echo "Current commit:"
git log -1
rm -rf dist/ # Clear dist directory first
npm ci # Install dependencies
npm run build # Build the project
# Stop and delete the existing PM2 process
pm2 stop agentic-placeholder-be || true
pm2 delete agentic-placeholder-be || true
# Start a new PM2 process using the npm script
npm run pm2:start
# Save the current process list
pm2 save
echo "Deployment successful!"
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}