-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c61d1ac
commit 00ffd7b
Showing
1 changed file
with
64 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build and Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install pnpm | ||
run: npm install -g pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build project | ||
run: pnpm run build | ||
|
||
- name: Clean target directory on server | ||
env: | ||
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }} | ||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }} | ||
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} | ||
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }} | ||
run: | | ||
echo "${{ secrets.DEPLOY_KEY }}" > deploy_key | ||
chmod 600 deploy_key | ||
ssh -i deploy_key ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_SERVER }} "rm -rf ${DEPLOY_PATH}/dist" | ||
rm deploy_key | ||
- name: Deploy to server | ||
env: | ||
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }} | ||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }} | ||
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} | ||
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }} | ||
run: | | ||
echo "${{ secrets.DEPLOY_KEY }}" > deploy_key | ||
chmod 600 deploy_key | ||
scp -i deploy_key -r dist/* ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_SERVER }}:${{ secrets.DEPLOY_PATH }}/dist | ||
rm deploy_key | ||
- name: Restart PM2 process | ||
env: | ||
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }} | ||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }} | ||
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} | ||
DEPLOY_APP_NAME: ${{ secrets.DEPLOY_APP_NAME }} | ||
run: | | ||
echo "${{ secrets.DEPLOY_KEY }}" > deploy_key | ||
chmod 600 deploy_key | ||
ssh -i deploy_key ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_SERVER }} "pm2 restart ${DEPLOY_APP_NAME}" | ||
rm deploy_key |