Repository navigation
106 lines (83 loc) · 2.82 KB
/
Copy pathdeploy.yml
File metadata and controls
106 lines (83 loc) · 2.82 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
name: Deploy
on:
push:
branches:
- main
concurrency:
group: deploy
cancel-in-progress: false
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
tools: composer:v2
coverage: none
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --prefer-dist
- name: Run static analysis
run: composer analyse
- name: Run code style check
run: composer sniff
- name: Run tests
run: composer test
deploy:
name: Deploy to Production
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
cache: "npm"
- name: Install npm dependencies
run: npm ci --no-audit --no-fund
- name: Build frontend assets
run: npm run build
- name: Upload build artifacts
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.DEPLOY_SSH_HOST }}
username: ${{ secrets.DEPLOY_SSH_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
source: "public/assets/,public/.vite/"
target: ${{ secrets.DEPLOY_PATH }}
- name: Deploy via SSH
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEPLOY_SSH_HOST }}
username: ${{ secrets.DEPLOY_SSH_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
script: |
set -e
echo ">>> Starting deployment..."
cd ${{ secrets.DEPLOY_PATH }}
echo ">>> Pulling latest code..."
# The machine-specific compose.override.yml may differ from git (or
# not be tracked at all); move it aside so the pull can't conflict
# with it, then restore it.
[ -f compose.override.yml ] && mv compose.override.yml /tmp/compose.override.yml.bak || true
git pull origin main
[ -f /tmp/compose.override.yml.bak ] && mv /tmp/compose.override.yml.bak compose.override.yml || true
echo ">>> Running deployment script..."
export DEPLOY_ENV=production
bash scripts/deploy.sh
echo ">>> Deployment complete!"