add ability to login to docker registry

This commit is contained in:
2025-12-22 00:42:00 +01:00
parent 90f83b775e
commit 8e9640a4fc
2 changed files with 50 additions and 1 deletions

View File

@@ -31,6 +31,9 @@ Robustly deploy your Docker Compose files to Docker Swarm or regular Docker Comp
| `build_context_path` | Local path to Docker build context | ❌ No | `build-context` |
| `copy_env_file` | Whether to copy `.env` file to remote host | ❌ No | `false` |
| `env_file_path` | Local path to `.env` file | ❌ No | `.env` |
| `docker_registry` | Docker registry URL (defaults to Docker Hub if empty) | ❌ No | - |
| `docker_username` | Docker registry username | ❌ No | - |
| `docker_password` | Docker registry password or token | ❌ No | - |
---
@@ -80,6 +83,22 @@ This action supports two deployment modes:
env_file_path: ./production.env
```
### Deploying with Private Registry Authentication 🔐
```yaml
- name: Deploy with Private Registry 🔐
uses: your-org/deploy-to-docker-action@main
with:
stack_name: my-private-stack
ssh_host: ${{ vars.SSH_HOST }}
ssh_user: ${{ secrets.SSH_USER }}
ssh_key: ${{ secrets.SSH_KEY }}
deploy_file: docker-compose.yml
docker_registry: ghcr.io
docker_username: ${{ github.actor }}
docker_password: ${{ secrets.GITHUB_TOKEN }}
```
---
## 🧑‍💻 How It Works
@@ -88,7 +107,8 @@ This action performs the following steps:
1. 🔑 **Securely creates a temporary SSH key file** for authentication.
2. 📁 **Creates a secure temporary directory** on the remote host.
3. 📤 **Copies your processed Docker Compose file** to the remote host.
3. 🔐 **Optionally performs Docker login** on the remote host if credentials are provided.
4. 📤 **Copies your processed Docker Compose file** to the remote host.
4. 📂 **Optionally copies Docker build context** to the remote host.
5. 📄 **Optionally copies `.env` file** to the remote host.
6. 🔍 **Validates the Docker Compose file remotely** to ensure correctness.