Skip to content

Commit

Permalink
feat: update node js workflow to automatically deploy to the server
Browse files Browse the repository at this point in the history
  • Loading branch information
rasulov1337 committed Dec 20, 2024
1 parent 93e2a48 commit d7f3e89
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/nodejs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
name: Node.js CI

on:
pull_request:
branches: ['*']
push:
branches: ['better-deploy', 'dev']

jobs:
build:
Expand All @@ -26,3 +26,28 @@ jobs:
- run: npm i
- run: npm run build
- run: npm test --if-present

deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get current branch name
id: branch_name
run: echo "BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT

- name: Install SSH Client
run: sudo apt-get update && sudo apt-get install -y openssh-client

- name: Add SSH key to the agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Create remote directory (if it doesn't exist)
run: ssh [email protected] "mkdir -p /home/ubuntu/frontend/"

- name: Copy build artifacts via SSH
run: rsync -avzP ./dist/ [email protected]:/home/ubuntu/frontend/

0 comments on commit d7f3e89

Please sign in to comment.