> For the complete CircleCI developer hub index, see [llms.txt](https://circleci.com/developer/llms.txt)

# topmonks/swarmpit

Deploy your stacks to Docker Swarm via Swarmpit API.


## Commands

### deploy_stack

Deploys docker-compose.yml file as a stack via Swarmpit API. Creates new or updates an existing stack. Swarmpit API Key and URL should be set via Context with SWARMPIT_API_URL and SWARMPIT_API_KEY variables.


| Parameter | Type | Default | Description |
|---|---|---|---|
| `stack_name` | string |  | Name of the stack to deploy. |
| `compose_file_path` | string | docker-compose.yml | Path to the stack definition (docker-compose) file. |
| `swarmpit_api_url` | string | $SWARMPIT_API_URL | URL of the API endpoint of your Swarmpit instance (eg. https://swarmpit.my.cloud/api). |
| `swarmpit_api_key` | string | $SWARMPIT_API_KEY | API Key to access the Swarmpit API. You will get it in Swarmpit account management. |

## Jobs

### deploy

Deploy stack to Swarmpit

| Parameter | Type | Default | Description |
|---|---|---|---|
| `executor` | executor | default | Executor to use for this job, defaults to this orb's `default` executor
 |
| `stack_name` | string |  | Name of the stack to deploy. |
| `compose_file_path` | string | docker-compose.yml | Path to the stack definition (docker-compose) file. |
| `swarmpit_api_url` | string | $SWARMPIT_API_URL | URL of the API endpoint of your Swarmpit instance (eg. https://swarmpit.my.cloud/api). |
| `swarmpit_api_key` | string | $SWARMPIT_API_KEY | API Key to access the Swarmpit API. You will get it in Swarmpit account management. |

## Executors

### default

The docker container to use when running this orb's jobs


| Parameter | Type | Default | Description |
|---|---|---|---|
| `image` | string | circleci/python | Docker image name |
| `tag` | string | 3.6 | Image tag |

## Examples

### stack_deploy

Push the newly built image to Docker Hub and then deploy the stack definition in ./docker-compose.yml to the Swarm. Swarmpit API endpoint and API Key are stored in the org-swarmpit CircleCI context.


```yaml
version: 2.1
orbs:
  docker: circleci/docker@1.4.0
  swarmpit: topmonks/swarmpit@1.0.0
workflows:
  build_and_deploy:
    jobs:
      - docker/publish:
          name: docker-publish
          context: org-docker
          image: my-org/my-service
          tag: latest
      - swarmpit/deploy:
          stack_name: my-service
          context: org-swarmpit
          requires:
            - docker-publish
```

### stack_deploy_job

Push the newly built image to Docker Hub and then deploy the stack definition in ./docker-compose.yml to the Swarm. Swarmpit API endpoint and API Key are stored in the org-swarmpit CircleCI context.


```yaml
version: 2.1
orbs:
  docker: circleci/docker@1.4.0
  swarmpit: topmonks/swarmpit@1.0.0
jobs:
  docker_deploy:
    executor: docker/docker
    steps:
      - setup_remote_docker
      - checkout
      - docker/check
      - docker/push:
          image: my-org/my-service
          tag: latest
      - swarmpit/deploy_stack:
          stack_name: my-service
workflows:
  build_and_deploy:
    jobs:
      - docker_deploy:
          context: org-swarmpit
          filters:
            branches:
              only: trunk
```