-
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (63 loc) · 2.1 KB
/
deploy-laravel-project.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
63
64
65
66
67
68
69
70
71
72
73
name: Deploy Laravel Project
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.LIMA_SSH_PRIVATE_KEY }}
- name: Add SSH key to known_hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan -H ${{ secrets.LIMA_SFTP_HOST }} >> ~/.ssh/known_hosts
- name: Test SSH connection
env:
SFTP_HOST: ${{ secrets.LIMA_SFTP_HOST }}
SFTP_USERNAME: ${{ secrets.LIMA_SFTP_USERNAME }}
run: |
ssh $SFTP_USERNAME@$SFTP_HOST "echo -------- Connection Successful --------"
- name: Upload files via SSH
env:
SFTP_HOST: ${{ secrets.LIMA_SFTP_HOST }}
SFTP_USERNAME: ${{ secrets.LIMA_SFTP_USERNAME }}
run: |
rsync -r --delete-after --quiet \
--exclude '/src/vendor/' \
--exclude 'node_modules/' \
--exclude 'storage/' \
--exclude '.env' \
--exclude 'bootstrap/cache/' \
--exclude 'public/css/' \
--exclude 'public/js/' \
--exclude 'database/database.sqlite' \
--exclude 'database/old_database.sqlite' \
$GITHUB_WORKSPACE/src/ $SFTP_USERNAME@$SFTP_HOST:oe-app/
- name: Upload .env file
env:
SFTP_HOST: ${{ secrets.LIMA_SFTP_HOST }}
SFTP_USERNAME: ${{ secrets.LIMA_SFTP_USERNAME }}
ENV_VARIABLES: ${{ secrets.ENV_VARIABLES }}
run: |
echo "$ENV_VARIABLES" | ssh $SFTP_USERNAME@$SFTP_HOST 'cat > oe-app/.env'
- name: Run remote SSH commands
env:
SFTP_HOST: ${{ secrets.LIMA_SFTP_HOST }}
SFTP_USERNAME: ${{ secrets.LIMA_SFTP_USERNAME }}
run: |
ssh $SFTP_USERNAME@$SFTP_HOST << 'EOF'
cd oe-app
composer install --no-interaction --prefer-dist --optimize-autoloader
npm install
npm run build
php artisan migrate --force
php artisan config:cache
php artisan storage:link
EOF