24 lines
966 B
YAML
24 lines
966 B
YAML
on:
|
|
workflow_call:
|
|
inputs:
|
|
build_cmd: { required: true, type: string }
|
|
dist_dir: { required: true, type: string }
|
|
ssh_user: { required: true, type: string }
|
|
ssh_host: { required: true, type: string }
|
|
remote_path: { required: true, type: string }
|
|
secrets:
|
|
SSH_KEY: { required: true }
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- run: ${{ inputs.build_cmd }}
|
|
- name: Add SSH key
|
|
run: |
|
|
mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
|
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
|
|
ssh-keyscan -H ${{ inputs.ssh_host }} >> ~/.ssh/known_hosts
|
|
- run: |
|
|
rsync -az --delete ${{ inputs.dist_dir }}/ ${{ inputs.ssh_user }}@${{ inputs.ssh_host }}:${{ inputs.remote_path }}/
|
|
ssh ${{ inputs.ssh_user }}@${{ inputs.ssh_host }} "sudo nginx -t && sudo systemctl reload nginx"
|