Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.

Commit 67e0754

Browse files
Update deployment workflow for Apache and migrations
1 parent 3147802 commit 67e0754

1 file changed

Lines changed: 47 additions & 42 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,55 @@
1-
name: Deploy to Server via SFTP
1+
name: Deploy to Apache
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches:
6+
- master
67

78
jobs:
89
deploy:
910
runs-on: ubuntu-latest
11+
1012
steps:
11-
- name: Checkout code
12-
uses: actions/checkout@v4
13-
14-
- name: Setup SSH key
15-
run: |
16-
mkdir -p ~/.ssh
17-
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
18-
chmod 600 ~/.ssh/deploy_key
19-
20-
- name: Generate SFTP commands with directory creation
21-
run: |
22-
# Start with changing to target directory
23-
echo "cd html" > sftp_commands.txt
24-
25-
# Find all directories that need to be created
26-
find . -type d -not -path "./.git*" -not -path "./.github*" | while read dir; do
27-
# Remove leading ./ and convert to server path
28-
target_dir="${dir#./}"
29-
if [ "$target_dir" != "." ]; then
30-
echo "-mkdir \"$target_dir\"" >> sftp_commands.txt
31-
fi
32-
done
33-
34-
# Add commands to upload all files
35-
find . -type f -not -path "./.git*" -not -path "./.github*" -not -path "./node_modules*" -not -name ".env" | while read file; do
36-
target_file="${file#./}"
37-
echo "put \"$file\" \"$target_file\"" >> sftp_commands.txt
38-
done
39-
40-
# Show the commands for debugging
41-
echo "=== SFTP Commands ==="
42-
cat sftp_commands.txt
43-
44-
- name: Execute SFTP deployment
45-
run: |
46-
sftp -b sftp_commands.txt \
47-
-P ${{ secrets.SERVER_PORT }} \
48-
-i ~/.ssh/deploy_key \
49-
-o StrictHostKeyChecking=accept-new \
50-
${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: Deploy Website
17+
uses: burnett01/rsync-deployments@6.0.0
18+
with:
19+
switches: -avzr --delete
20+
path: src/
21+
remote_path: /var/www/html/
22+
remote_host: ${{ secrets.SERVER_HOST }}
23+
remote_port: ${{ secrets.SERVER_PORT }}
24+
remote_user: ${{ secrets.SERVER_USERNAME }}
25+
remote_key: ${{ secrets.SSH_PRIVATE_KEY }}
26+
27+
- name: Deploy database migrations
28+
uses: burnett01/rsync-deployments@6.0.0
29+
with:
30+
switches: -avzr --delete
31+
path: db/
32+
remote_path: /var/www/html/db/
33+
remote_host: ${{ secrets.SERVER_HOST }}
34+
remote_port: ${{ secrets.SERVER_PORT }}
35+
remote_user: ${{ secrets.SERVER_USERNAME }}
36+
remote_key: ${{ secrets.SSH_PRIVATE_KEY }}
37+
38+
- name: Run Flyway migrations
39+
uses: appleboy/ssh-action@v1.0.3
40+
with:
41+
host: ${{ secrets.SERVER_HOST }}
42+
port: ${{ secrets.SERVER_PORT }}
43+
username: ${{ secrets.SERVER_USERNAME }}
44+
key: ${{ secrets.SSH_PRIVATE_KEY }}
45+
script: |
46+
set -e
47+
48+
flyway \
49+
-url='${{ secrets.DB_URL }}' \
50+
-user='${{ secrets.DB_USER }}' \
51+
-password='${{ secrets.DB_PASS }}' \
52+
-locations='filesystem:/var/www/html/db/migrations' \
53+
migrate
54+
55+
echo "Migrations complete"

0 commit comments

Comments
 (0)