-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (112 loc) Β· 3.94 KB
/
deploy.yml
File metadata and controls
127 lines (112 loc) Β· 3.94 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Deploy to Production
on:
push:
branches:
- main
pull_request:
types:
- closed
branches:
- main
workflow_dispatch: # Allows manual trigger
jobs:
build-and-deploy:
name: π Build & Deploy
# Only run deployment if push to main or if PR is merged to main
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
environment: production
env:
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }}
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.VITE_FIREBASE_AUTH_DOMAIN }}
VITE_FIREBASE_PROJECT_ID: ${{ secrets.VITE_FIREBASE_PROJECT_ID }}
VITE_FIREBASE_STORAGE_BUCKET: ${{ secrets.VITE_FIREBASE_STORAGE_BUCKET }}
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.VITE_FIREBASE_MESSAGING_SENDER_ID }}
VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID }}
steps:
- name: π Get latest code
uses: actions/checkout@v3
- name: βοΈ Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
# Verify all required secrets are set
- name: π Verify deployment secrets
run: |
# Check FTP credentials
if [ -z "${{ secrets.FTP_SERVER }}" ]; then
echo "::error::FTP_SERVER secret is not set"
exit 1
fi
if [ -z "${{ secrets.FTP_USERNAME }}" ]; then
echo "::error::FTP_USERNAME secret is not set"
exit 1
fi
if [ -z "${{ secrets.FTP_PASSWORD }}" ]; then
echo "::error::FTP_PASSWORD secret is not set"
exit 1
fi
# Check Firebase configuration
FIREBASE_VARS=(
"VITE_FIREBASE_API_KEY"
"VITE_FIREBASE_AUTH_DOMAIN"
"VITE_FIREBASE_PROJECT_ID"
"VITE_FIREBASE_STORAGE_BUCKET"
"VITE_FIREBASE_MESSAGING_SENDER_ID"
"VITE_FIREBASE_APP_ID"
)
for var in "${FIREBASE_VARS[@]}"; do
if [ -z "${!var}" ]; then
echo "::error::$var is not set"
exit 1
fi
done
echo "β
All required secrets are properly configured"
# Cache dependencies
- name: π¦ Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
- name: π¦ Install dependencies
run: |
echo "Installing dependencies..."
npm ci
echo "β
Dependencies installed successfully"
- name: ποΈ Build project
id: build
run: |
echo "Building project..."
npm run build -- --mode production
if [ ! -d "dist" ]; then
echo "::error::Build failed - dist directory not created"
exit 1
fi
echo "β
Build completed successfully"
echo "π Build size: $(du -sh dist | cut -f1)"
- name: π Deploy to Hostinger
uses: SamKirkland/FTP-Deploy-Action@v4.3.4
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./dist/
server-dir: /public_html/
dangerous-clean-slate: true # Removes all files in the remote directory before uploading
timeout: 60000 # Increase timeout for large deployments
exclude: |
**/.git*
**/.git*/**
**/node_modules/**
README.md
- name: β
Deployment Status
if: always()
run: |
if [ "${{ job.status }}" = "success" ]; then
echo "β
Deployment completed successfully!"
else
echo "β Deployment failed"
exit 1
fi