Improve deploy error reporting
All checks were successful
Deploy Blog / deploy (push) Successful in 25s
All checks were successful
Deploy Blog / deploy (push) Successful in 25s
This commit is contained in:
parent
203405b86f
commit
1c0f69d413
1 changed files with 18 additions and 6 deletions
|
|
@ -43,6 +43,10 @@ jobs:
|
|||
BLOG_DEPLOY_KEY: ${{ secrets.BLOG_DEPLOY_KEY }}
|
||||
BLOG_DEPLOY_KNOWN_HOSTS: ${{ secrets.BLOG_DEPLOY_KNOWN_HOSTS }}
|
||||
run: |
|
||||
if [ -z "${BLOG_DEPLOY_KEY}" ]; then
|
||||
echo "Missing required secret: BLOG_DEPLOY_KEY"
|
||||
exit 1
|
||||
fi
|
||||
install -d -m 700 ~/.ssh
|
||||
printf '%s\n' "$BLOG_DEPLOY_KEY" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
|
|
@ -58,15 +62,23 @@ jobs:
|
|||
BLOG_DEPLOY_USER: ${{ secrets.BLOG_DEPLOY_USER }}
|
||||
BLOG_DEPLOY_PATH: ${{ secrets.BLOG_DEPLOY_PATH }}
|
||||
run: |
|
||||
test -n "$BLOG_DEPLOY_HOST"
|
||||
test -n "$BLOG_DEPLOY_PORT"
|
||||
test -n "$BLOG_DEPLOY_USER"
|
||||
test -n "$BLOG_DEPLOY_PATH"
|
||||
missing=""
|
||||
for var in BLOG_DEPLOY_HOST BLOG_DEPLOY_PORT BLOG_DEPLOY_USER BLOG_DEPLOY_PATH; do
|
||||
eval value="\${$var}"
|
||||
if [ -z "$value" ]; then
|
||||
missing="$missing $var"
|
||||
fi
|
||||
done
|
||||
if [ -n "$missing" ]; then
|
||||
echo "Missing required secrets:$missing"
|
||||
exit 1
|
||||
fi
|
||||
echo "Deploy target: ${BLOG_DEPLOY_USER}@${BLOG_DEPLOY_HOST}:${BLOG_DEPLOY_PATH} (port ${BLOG_DEPLOY_PORT})"
|
||||
SSH_OPTS="-p $BLOG_DEPLOY_PORT"
|
||||
if [ ! -f ~/.ssh/known_hosts ]; then
|
||||
SSH_OPTS="$SSH_OPTS -o StrictHostKeyChecking=accept-new"
|
||||
fi
|
||||
ssh $SSH_OPTS "$BLOG_DEPLOY_USER@$BLOG_DEPLOY_HOST" "mkdir -p '$BLOG_DEPLOY_PATH/public'"
|
||||
rsync -az --delete \
|
||||
ssh $SSH_OPTS "$BLOG_DEPLOY_USER@$BLOG_DEPLOY_HOST" "echo Connected to $(hostname); mkdir -p '$BLOG_DEPLOY_PATH/public'"
|
||||
rsync -avz --delete \
|
||||
-e "ssh $SSH_OPTS" \
|
||||
public/ "$BLOG_DEPLOY_USER@$BLOG_DEPLOY_HOST:$BLOG_DEPLOY_PATH/public/"
|
||||
|
|
|
|||
Loading…
Reference in a new issue