runner v7
All checks were successful
CI Deploy Laravel / Test (push) Successful in 1m33s
CI Deploy Laravel / Build (push) Successful in 3m21s
CI Deploy Laravel / Deploy (push) Successful in 1m27s

This commit is contained in:
pesu98
2026-05-13 15:23:31 +08:00
parent d00fea4ecb
commit db7b8751ec

View File

@@ -108,22 +108,18 @@ jobs:
name: laravel-build name: laravel-build
path: release path: release
- name: Install sshpass - name: Install SSH deployment tools
run: sudo apt-get update && sudo apt-get install -y sshpass run: sudo apt-get update && sudo apt-get install -y openssh-client sshpass rsync
- name: Install rsync - name: Configure SSH
run: sudo apt-get install -y rsync
- name: Add SSH host to known_hosts
env: env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }} DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
run: | run: |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
if [ -n "$DEPLOY_KNOWN_HOSTS" ]; then if [ -n "$DEPLOY_KNOWN_HOSTS" ]; then
echo "$DEPLOY_KNOWN_HOSTS" >> ~/.ssh/known_hosts echo "$DEPLOY_KNOWN_HOSTS" >> ~/.ssh/known_hosts
else chmod 600 ~/.ssh/known_hosts
ssh-keyscan -p "${DEPLOY_PORT:-22}" "$DEPLOY_HOST" >> ~/.ssh/known_hosts
fi fi
- name: Deploy files with rsync over SSH - name: Deploy files with rsync over SSH
@@ -141,8 +137,8 @@ jobs:
fi fi
mkdir -p ~/.ssh mkdir -p ~/.ssh
rsync -az --delete \ sshpass -e rsync -az --delete \
-e "sshpass -e ssh -p ${DEPLOY_PORT:-22}" \ -e "ssh -p ${DEPLOY_PORT:-22} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=password -o PubkeyAuthentication=no -o NumberOfPasswordPrompts=1" \
--exclude='.env' \ --exclude='.env' \
--exclude='storage/' \ --exclude='storage/' \
--exclude='storage/logs/*' \ --exclude='storage/logs/*' \
@@ -151,7 +147,15 @@ jobs:
--exclude='storage/framework/views/*' \ --exclude='storage/framework/views/*' \
release/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}" release/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}"
sshpass -e ssh -p "${DEPLOY_PORT:-22}" "${DEPLOY_USER}@${DEPLOY_HOST}" "test -f \"${DEPLOY_PATH}/public/.htaccess\" || { echo 'public/.htaccess missing after rsync'; exit 1; }" sshpass -e ssh \
-p "${DEPLOY_PORT:-22}" \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o PreferredAuthentications=password \
-o PubkeyAuthentication=no \
-o NumberOfPasswordPrompts=1 \
"${DEPLOY_USER}@${DEPLOY_HOST}" \
"test -f \"${DEPLOY_PATH}/public/.htaccess\" || { echo 'public/.htaccess missing after rsync'; exit 1; }"
- name: Create .env on server from secret - name: Create .env on server from secret
env: env:
@@ -173,7 +177,15 @@ jobs:
exit 1 exit 1
fi fi
printf '%s' "$DEPLOY_ENV_FILE" | sshpass -e ssh -p "${DEPLOY_PORT:-22}" "${DEPLOY_USER}@${DEPLOY_HOST}" "mkdir -p \"${DEPLOY_PATH}\" && cat > \"${DEPLOY_PATH}/.env\" && chmod 600 \"${DEPLOY_PATH}/.env\"" printf '%s' "$DEPLOY_ENV_FILE" | sshpass -e ssh \
-p "${DEPLOY_PORT:-22}" \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o PreferredAuthentications=password \
-o PubkeyAuthentication=no \
-o NumberOfPasswordPrompts=1 \
"${DEPLOY_USER}@${DEPLOY_HOST}" \
"mkdir -p \"${DEPLOY_PATH}\" && cat > \"${DEPLOY_PATH}/.env\" && chmod 600 \"${DEPLOY_PATH}/.env\""
- name: Run post-deploy Laravel commands - name: Run post-deploy Laravel commands
env: env:
@@ -189,7 +201,15 @@ jobs:
exit 1 exit 1
fi fi
sshpass -e ssh -p "${DEPLOY_PORT:-22}" "${DEPLOY_USER}@${DEPLOY_HOST}" "cd ${DEPLOY_PATH} && mkdir -p storage/framework/cache/data storage/framework/sessions storage/framework/views storage/logs bootstrap/cache && chmod -R ug+rw storage bootstrap/cache && php artisan optimize:clear && php artisan config:cache && php artisan route:cache && php artisan view:cache" sshpass -e ssh \
-p "${DEPLOY_PORT:-22}" \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o PreferredAuthentications=password \
-o PubkeyAuthentication=no \
-o NumberOfPasswordPrompts=1 \
"${DEPLOY_USER}@${DEPLOY_HOST}" \
"cd ${DEPLOY_PATH} && mkdir -p storage/framework/cache/data storage/framework/sessions storage/framework/views storage/logs bootstrap/cache && chmod -R ug+rw storage bootstrap/cache && php artisan optimize:clear && php artisan config:cache && php artisan route:cache && php artisan view:cache"
# Required repository secrets: # Required repository secrets:
# - DEPLOY_HOST: Server hostname or IP. # - DEPLOY_HOST: Server hostname or IP.