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

Commit 3147802

Browse files
Update deploy.yml
1 parent 2633b88 commit 3147802

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,34 @@ jobs:
1717
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
1818
chmod 600 ~/.ssh/deploy_key
1919
20-
- name: Deploy with rsync
20+
- name: Generate SFTP commands with directory creation
2121
run: |
22-
rsync -avz --delete \
23-
-e "ssh -p ${{ secrets.SERVER_PORT }} -i ~/.ssh/deploy_key -o StrictHostKeyChecking=accept-new" \
24-
--exclude '.git' \
25-
--exclude '.github' \
26-
--exclude 'node_modules' \
27-
--exclude '.env' \
28-
--exclude '.gitignore' \
29-
./ ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}:/var/www/html/
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 }}

0 commit comments

Comments
 (0)