A Forgejo Action to deploy a Docker Stack (Compose) to a Docker Swarm cluster over SSH.
Find a file
2026-03-16 11:11:43 +00:00
action.yml Actualiser action.yml 2026-03-16 11:11:43 +00:00
LICENSE Initial commit 2025-12-01 08:45:24 +00:00
README.md Actualiser README.md 2026-03-03 11:13:41 +00:00

🚀 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. Its 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

Heres 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_KEY
    • DOCKER_SSH_HOST
    • DOCKER_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 deploy remotely, 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:

  1. Fork the repository
  2. Make your changes
  3. Open a Pull Request

Lets make Docker Swarm deployments easier and more reliable with Forgejo Actions! 🎯