-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (53 loc) · 1.58 KB
/
deploy.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
60
61
62
name: Deploy to Production
on:
workflow_dispatch:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
hosts: ${{ steps.set-hosts.outputs.hosts }}
steps:
- id: set-hosts
name: Set hosts
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
run: |
echo 'hosts=$DEPLOY_HOST' >> $GITHUB_OUTPUT
deploy:
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
host: ${{ fromJson(needs.prepare.outputs.hosts) }}
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup SSH
uses: webfactory/ssh-agent@v0.8.0
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Add host key
env:
DEPLOY_HOST: ${{ matrix.host }}
run: |
mkdir -p ~/.ssh
ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
- name: Install Composer
uses: php-actions/composer@v6
with:
php_version: '8.3'
version: '2.8.4'
- name: Install composer dependencies
run: |
cd app
composer install --no-dev
cd ..
- name: Deploy to production
env:
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_HOST: ${{ matrix.host }}
run: |
rsync -avz --delete app/src/ "$DEPLOY_USER@$DEPLOY_HOST:/var/www/html/src"
rsync -avz --delete app/vendor/ "$DEPLOY_USER@$DEPLOY_HOST:/var/www/html/vendor"
rsync -avz app/index.php "$DEPLOY_USER@$DEPLOY_HOST:/var/www/html/index.php"