Skip to content

Update main.yml

Update main.yml #3

Workflow file for this run

name: Deploy to Alibaba ECS
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Copy files to Alibaba ECS
run: |
ssh-keyscan -H ${{ secrets.ECS_HOST }} >> ~/.ssh/known_hosts
scp -r ./* ${{ secrets.ECS_USER }}@${{ secrets.ECS_HOST }}:${{ secrets.ECS_PATH }}
- name: Set up Node.js
uses: actions/[email protected]
with:
node-version: 20.15.1
- name: SSH and deploy
run: |
ssh ${{ secrets.ECS_USER }}@${{ secrets.ECS_HOST }} << 'EOF'
cd ${{ secrets.ECS_PATH }}
# Pull latest changes
git pull origin main
# Install dependencies
nvm use 20
npm install
# Build the project
npm run build
# Restart the application
pm2 restart artistica-api
EOF