setup-ssh-client/.github/workflows/example.yml

70 lines
2 KiB
YAML

# Example workflow demonstrating the setup-ssh-client action
name: Deploy Example
on:
workflow_dispatch:
jobs:
deploy-with-shell-wrapper:
name: Deploy using ssh-remote shell
if: always() == 'false'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup SSH
uses: ./
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh-host: ${{ secrets.SSH_HOST }}
ssh-user: ${{ secrets.SSH_USER }}
# Try turning on the shell wrapper debug if the job succeeds but
# produces no visible output. This will print the temp script and
# its contents to the step log.
debug-shell-wrapper: 'true'
- name: Check system info
shell: ssh-remote {0}
run: |
echo "=== System Information ==="
whoami
hostname
uname -a
pwd
- name: Run deployment script
shell: ssh-remote {0}
run: |
echo "=== Starting Deployment ==="
cd /var/www || cd ~
# Example deployment commands
echo "Current directory: $(pwd)"
echo "Disk usage:"
df -h | head -n 5
echo "✅ Deployment completed"
deploy-direct-ssh:
name: Deploy using direct SSH
if: always() == 'false'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup SSH (without shell wrapper)
uses: ./
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh-host: ${{ secrets.SSH_HOST }}
ssh-user: ${{ secrets.SSH_USER }}
use-shell-wrapper: 'false'
- name: Run direct SSH commands
run: |
echo "Running remote commands via SSH..."
ssh github-action-host "whoami"
ssh github-action-host "pwd"
ssh github-action-host "uname -a"