-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (51 loc) · 1.67 KB
/
github-action.yml
File metadata and controls
61 lines (51 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Deploy Vite Project to Nginx Server
on:
push:
branches:
- develop
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# 1. Checkout the code from GitHub
- name: Checkout repository
uses: actions/checkout@v2
# 2. Set the VITE_API_URL environment variable
- name: Create .env file
run: |
echo ${{ secrets.HOST_NAME }} > .env
cat .env
# 2. Set up Node.js 22
- name: Set up Node.js 22
uses: actions/setup-node@v2
with:
node-version: '22'
# 3. Install dependencies
- name: Install dependencies
run: npm install
# 4. Build the project with Vite
- name: Build with Vite
run: npx vite build
# 5. SCP the build files to the remote server
- name: SCP build files to remote server
uses: appleboy/scp-action@v0.1.0
with:
host: ${{ secrets.AWS_HOST }}
username: changuii
password: ${{ secrets.AWS_PASSWORD }}
port: ${{ secrets.AWS_PORT }}
source: "./dist/*"
target: ${{ secrets.TARGET_DIRECTORY }}
# 6. Deploy the build folder to the remote server
- name: Deploy to server via SSH
uses: appleboy/ssh-action@v0.1.0
with:
host: ${{ secrets.AWS_HOST }}
username: changuii
password: ${{ secrets.AWS_PASSWORD }}
port: ${{ secrets.AWS_PORT }}
script: |
# Delete old files in the web server folder
sudo rm -rf ./clickmeee/web/files/dist
sudo mv ./clickmeee/deploy_data/dist ./clickmeee/web/files
sudo rm -rf ./clickmeee/deploy_data/dist