summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIwanIDev <iwan@iwani.dev>2026-03-04 16:47:49 +0000
committerIwanIDev <iwan@iwani.dev>2026-03-04 16:47:49 +0000
commitd71b428aff18f18c6d8b8e36b08d6e6caf9e2b22 (patch)
tree14f410c9d042d29a52cfd6d953b59592fbe137ee
parentbe721cffd0fc55ef665912ceec8edcb2e37ca326 (diff)
Fix Docker deployment setup
-rw-r--r--.github/workflows/docker_build.yml28
1 files changed, 22 insertions, 6 deletions
diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml
index 01e8e50..737fd2e 100644
--- a/.github/workflows/docker_build.yml
+++ b/.github/workflows/docker_build.yml
@@ -62,19 +62,35 @@ jobs:
uses: actions/checkout@v4
- name: Setup SSH key for Docker context
+ env:
+ DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
+ DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
+ DEPLOY_PORT: ${{ secrets.DEPLOY_PORT || 22 }}
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
- ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
+ ssh-keyscan -H $DEPLOY_HOST >> ~/.ssh/known_hosts
+
+ # Create SSH config to use only the specific key and prevent trying multiple auth methods
+ cat > ~/.ssh/config << EOF
+ Host deploy-target
+ HostName $DEPLOY_HOST
+ User $DEPLOY_USER
+ Port $DEPLOY_PORT
+ IdentityFile ~/.ssh/deploy_key
+ IdentitiesOnly yes
+ PubkeyAuthentication yes
+ PasswordAuthentication no
+ EOF
+ chmod 600 ~/.ssh/config
+
+ # Test the connection
+ ssh -o BatchMode=yes deploy-target "echo 'SSH connection successful'"
- name: Create Docker context
- env:
- DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
- DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
- DEPLOY_PORT: ${{ secrets.DEPLOY_PORT || 22 }}
run: |
- docker context create remote --docker "host=ssh://$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PORT"
+ docker context create remote --docker "host=ssh://deploy-target"
docker context use remote
docker context ls