-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (59 loc) · 1.74 KB
/
deploy-staging-frontend.yml
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
name: Build and Deploy Preview / Frontend
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'frontend/**'
jobs:
build-and-deploy-frontend:
runs-on: ubuntu-latest
environment: Staging
defaults:
run:
shell: bash
working-directory: frontend
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup VPS fingerprint
run: |
mkdir -p ~/.ssh
echo "${{ secrets.VPS_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "${{ secrets.VPS_IP }} ${{ secrets.VPS_FINGERPRINT }}" >> ~/.ssh/known_hosts
- name: Setup Rsync
uses: GuillaumeFalourd/[email protected]
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build environment
run: |
cat << EOF > .env
VITE_API_URL=${{ secrets.BACKEND_URL }}/api/v1
EOF
- name: Build
run: pnpm build
- name: Deploy to server
run: |
rsync -avz --progress dist/* "${{ secrets.VPS_USER }}@${{ secrets.VPS_IP }}:~/${{ secrets.APP_ENV }}/frontend"