From 4ea5083a733f2dd4cc00e22e7fc24fe8bf8e7749 Mon Sep 17 00:00:00 2001 From: jkellerer Date: Wed, 31 Jan 2024 08:25:14 +0100 Subject: [PATCH] fix: ssh to server --- .github/workflows/ansibleOnServer.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ansibleOnServer.yml b/.github/workflows/ansibleOnServer.yml index 9ebc64b..b7a74cc 100644 --- a/.github/workflows/ansibleOnServer.yml +++ b/.github/workflows/ansibleOnServer.yml @@ -28,6 +28,19 @@ jobs: - name: Check out repository code uses: actions/checkout@v2 + - name: Set up SSH key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SERVER_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan -H ${{ secrets.SERVER_IP_ADDRESS }} >> ~/.ssh/known_hosts + eval "$(ssh-agent -s)" + ssh-add ~/.ssh/id_rsa + + - name: Test SSH connection + run: | + ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP_ADDRESS }} exit + - name: Set up Python uses: actions/setup-python@v2 with: @@ -46,15 +59,6 @@ jobs: python -m pip install --upgrade pip pip install -r server/provision/requirements.txt - - name: Set up SSH key - run: | - mkdir -p ~/.ssh - echo "${{ secrets.SERVER_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh-keyscan -H ${{ secrets.SERVER_IP_ADDRESS }} >> ~/.ssh/known_hosts - eval "$(ssh-agent -s)" - ssh-add ~/.ssh/id_rsa - - name: Run Ansible run: | ansible-playbook --inventory server/provision/inventory_for_ci.yml --extra-vars "remote_server_user=${{ secrets.SERVER_USER }} remote_server_password=${{ secrets.SERVER_USER_PASSWORD }}" ${{ inputs.ansible_file }} \ No newline at end of file