All checks were successful
Deploy to Server / deploy (push) Successful in 30s
- Consolidates SSH setup and deployment into a single step. - Simplifies the deployment workflow by combining steps. - Uses a more concise SSH command for deployment. - Removes unnecessary SSH key agent initialization. - Uses relative path `repo` in the deployment command.
31 lines
806 B
YAML
31 lines
806 B
YAML
name: Deploy to Server
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup SSH agent and deploy
|
|
run: |
|
|
eval "$(ssh-agent -s)"
|
|
mkdir -p ~/.ssh
|
|
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
|
chmod 700 ~/.ssh
|
|
ssh-keyscan "$SSH_HOST" >> ~/.ssh/known_hosts
|
|
chmod 644 ~/.ssh/known_hosts
|
|
|
|
ssh -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" "cd repo && git stash && git pull --force origin master && ./build.sh"
|
|
env:
|
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
SSH_USER: ${{ secrets.SSH_USER }}
|
|
SSH_HOST: ${{ secrets.SSH_HOST }}
|
|
SSH_PORT: ${{ secrets.SSH_PORT }}
|