| action.yml | ||
| LICENSE | ||
| README.md | ||
🚀 swarm-deploy-stack-action
A Forgejo Action to deploy a Docker Stack (Compose) to a Docker Swarm cluster over SSH.
This action connects to a remote Docker Swarm manager using SSH and deploys a stack file via docker stack deploy. It’s ideal for automating Swarm deployments directly from your CI/CD pipeline.
📦 Features
- 🔑 Connect to a remote Swarm manager using SSH
- 📦 Deploy a Docker Compose stack as a Docker Swarm stack
- 🔐 Support for registry authentication (username/password)
- 📍 Simple integration into Forgejo Actions workflows
⬇️ Inputs
| Input | Required | Description |
|---|---|---|
stack_name |
✅ | Name of the Swarm stack to deploy |
docker_compose_file |
✅ | Path to the Compose file to deploy |
docker_ssh_private_key |
✅ | SSH private key used to connect to the Swarm manager |
docker_ssh_host |
✅ | Hostname or IP of the Swarm manager (SSH target) |
docker_ssh_user |
✅ | Username for the SSH connection |
registry_username |
✅ | Username for Docker registry authentication |
registry_password |
✅ | Password (or token) for Docker registry authentication |
These inputs are exposed as environment variables or CLI flags internally.
📌 Basic Usage
Here’s an example of how to use this Action in a workflow:
name: Deploy to Swarm
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Deploy stack to Docker Swarm
uses: https://forge.jeckel.fr/forgejo/swarm-deploy-stack-action@v1.1
with:
stack_name: "my-app"
docker_compose_file: "docker-compose-stack.yml"
docker_ssh_private_key: ${{ secrets.DOCKER_SSH_PRIVATE_KEY }}
docker_ssh_host: ${{ secrets.DOCKER_SSH_HOST }}
docker_ssh_user: ${{ secrets.DOCKER_SSH_USER }}
registry_username: ${{ secrets.REGISTRY_USERNAME }}
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
Use this workflow to automate deployments whenever code is pushed to the main branch.
🔒 Security Best Practices
-
Never store private SSH keys or registry credentials in plaintext.
-
Always use Forgejo Secrets to store sensitive values like:
DOCKER_SSH_PRIVATE_KEYDOCKER_SSH_HOSTDOCKER_SSH_USER- Registry credentials
-
Consider using SSH trusted hosts or SSH config for additional security.
🧠 Notes
- This action relies on SSH to run
docker stack deployremotely, so the target must be reachable and configured to accept SSH connections. - Ensure that the target Docker node is a manager in the Swarm, as only managers can perform stack deployments.
- If deploying services using a private registry, login before the deploy step or provide registry credentials as shown.
📝 License
This repository follows the MIT License (see LICENSE file).
🙌 Contributing
Contributions, issues, and feature requests are welcome.
To contribute:
- Fork the repository
- Make your changes
- Open a Pull Request
Let’s make Docker Swarm deployments easier and more reliable with Forgejo Actions! 🎯