Skip to content

Edit pipeline

Edit pipeline #9

# .github/workflows/vm-access.yml
name: Test Pipeline
on:
push:
branches: [ "Pipeline" ]
workflow_dispatch:
inputs:
message:
description: 'URL to download with wget'
required: true
default: 'https://example.com/file.zip'
target_branch:
description: 'Branch to run from'
required: false
default: 'Pipeline'
jobs:
access-to-virtual-machine:
runs-on: ubuntu-latest
steps:
- name: Install tools
run: sudo apt-get update && sudo apt-get install -y expect
- name: Access to virtual machine
env:
SERVER1_HOST: ${{ secrets.SERVER1_HOST }}
SERVER1_USER: ${{ secrets.SERVER1_USER }}
SERVER1_PASS: ${{ secrets.SERVER1_PASS }}
SERVER2_HOST: ${{ secrets.SERVER2_HOST }}
SERVER2_USER: ${{ secrets.SERVER2_USER }}
SERVER2_PASS: ${{ secrets.SERVER2_PASS }}
WGET_URL: ${{ github.event.inputs.wget_url || 'https://httpbin.org/json' }}
run: |
# Method 1: Use expect to handle SSH password prompts
expect << EOF
spawn ssh -o StrictHostKeyChecking=no $SERVER1_USER@$SERVER1_HOST
expect "password:"
send "$SERVER1_PASS\r"
expect "$ "
send "ssh -o StrictHostKeyChecking=no $SERVER2_USER@$SERVER2_HOST\r"
expect "password:"
send "$SERVER2_PASS\r"
expect "$ "
send "echo 'Connected to Server2' && hostname\r"
expect "$ "
send "alias\r"
expect "$ "
send "vocms0500\r"
expect "$ "
send "ll\r"
expect "$ "
EOF