Compare Files Over SSH #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Configure SSH | |
on: [workflow_dispatch] | |
jobs: | |
SSH_Configuration: | |
runs-on: ubuntu-latest | |
env: | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | |
REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
LOCAL_PATH: ${{ secrets.LOCAL_PATH }} | |
REMOTE_PATH: ${{ secrets.REMOTE_PATH }} | |
SSH_KEY: ${{ secrets.REMOTE_KEY }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/[email protected] | |
with: | |
sparse-checkout: | | |
compare | |
sparse-checkout-cone-mode: false | |
- name: Configure SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "${{ env.SSH_KEY }}" | tr -d '\r' > ~/.ssh/remote_key | |
echo "Checking permissions of remote_key before" | |
ls -l ~/.ssh/remote_key | |
echo "Changing permissions of remote_key" | |
chmod 600 ~/.ssh/remote_key | |
echo "Checking permissions of remote_key after the change" | |
ls -l ~/.ssh/remote_key | |
cat >>~/.ssh/config <<END | |
Host test_env | |
HostName $REMOTE_HOST | |
User $REMOTE_USER | |
IdentityFile ~/.ssh/remote_key | |
StrictHostKeyChecking no | |
END | |
echo "Checking contents of SSH configuration file" | |
echo "---" | |
cat ~/.ssh/config | |
echo "---" | |
echo "SSH configuration completed successfully." | |
ls -la ~/.ssh/ | |
- name: Copy files from Remote to GH Actions runner | |
run: | | |
echo "Starting to copy files from remote to GH Actions runner" | |
ssh -tt test_env << 'EOF' | |
echo "SSH Connection Successful" | |
cd /var/www/compare/ | |
ls -la | |
#sscp -r $REMOTE_PATH $LOCAL_PATH | |
exit | |
EOF |