-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update node js workflow to automatically deploy to the server
- Loading branch information
1 parent
93e2a48
commit d7f3e89
Showing
1 changed file
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
name: Node.js CI | ||
|
||
on: | ||
pull_request: | ||
branches: ['*'] | ||
push: | ||
branches: ['better-deploy', 'dev'] | ||
|
||
jobs: | ||
build: | ||
|
@@ -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/ |