runner v7
This commit is contained in:
@@ -84,6 +84,7 @@ jobs:
|
|||||||
config
|
config
|
||||||
database
|
database
|
||||||
public
|
public
|
||||||
|
public/.htaccess
|
||||||
resources
|
resources
|
||||||
routes
|
routes
|
||||||
vendor
|
vendor
|
||||||
@@ -105,22 +106,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
|
||||||
env:
|
env:
|
||||||
@@ -137,7 +134,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
rsync -az --delete \
|
rsync -az --delete \
|
||||||
-e "sshpass -e ssh -p ${DEPLOY_PORT:-22}" \
|
-e "sshpass -e ssh -p ${DEPLOY_PORT:-22} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \
|
||||||
--exclude='.env' \
|
--exclude='.env' \
|
||||||
--exclude='storage/' \
|
--exclude='storage/' \
|
||||||
--exclude='storage/logs/*' \
|
--exclude='storage/logs/*' \
|
||||||
@@ -163,7 +160,12 @@ jobs:
|
|||||||
echo "DEPLOY_PASSWORD secret is empty."
|
echo "DEPLOY_PASSWORD secret is empty."
|
||||||
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 \
|
||||||
|
"${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:
|
||||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
@@ -177,7 +179,12 @@ jobs:
|
|||||||
echo "DEPLOY_PASSWORD secret is empty."
|
echo "DEPLOY_PASSWORD secret is empty."
|
||||||
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 \
|
||||||
|
"${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.
|
||||||
# - DEPLOY_PORT: SSH port (optional, defaults to 22).
|
# - DEPLOY_PORT: SSH port (optional, defaults to 22).
|
||||||
@@ -185,4 +192,4 @@ jobs:
|
|||||||
# - DEPLOY_PASSWORD: SSH password for deployment user.
|
# - DEPLOY_PASSWORD: SSH password for deployment user.
|
||||||
# - DEPLOY_PATH: Absolute path of the Laravel app on the server.
|
# - DEPLOY_PATH: Absolute path of the Laravel app on the server.
|
||||||
# - DEPLOY_KNOWN_HOSTS: Optional pinned known_hosts line(s) for stricter host verification.
|
# - DEPLOY_KNOWN_HOSTS: Optional pinned known_hosts line(s) for stricter host verification.
|
||||||
# - DEPLOY_ENV_FILE: Full .env content as a multiline secret (contains APP_KEY, DB_*, etc).
|
# - DEPLOY_ENV_FILE: Full .env content as a multiline secret (contains APP_KEY, DB_*, etc).
|
||||||
|
|||||||
Reference in New Issue
Block a user