Skip to content
layers

GitHub Action

Docker Stack Deploy

v1.0.0 Latest version

Docker Stack Deploy

layers

Docker Stack Deploy

Deploy a Docker Stack

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Docker Stack Deploy

uses: cssnr/[email protected]

Learn more about this action in cssnr/stack-deploy-action

Choose a version

Tags Test GitHub Release Version GitHub Last Commit Codeberg Last Commit GitHub Top Language GitHub Org Stars Discord

Docker Stack Deploy Action

This action deploys a docker stack from a compose file to a remote docker host using SSH Password or Key File Authentication.

For more details see action.yaml and src/main.sh.

Inputs

input required default description
host Yes - Remote Docker hostname
port No 22 Remote Docker port
user Yes - Remote Docker username
pass No - Remote Docker password *
ssh_key No - Remote SSH Key file *
file No docker-compose.yaml Docker Compose file
name Yes - Docker Stack name
env_file No - Docker Environment file

pass/ssh_key - You must provide either a pass or ssh_key

- name: 'Docker Stack Deploy'
  uses: cssnr/stack-deploy-action@v1
  with:
    host: ${{ secrets.DOCKER_HOST }}
    port: ${{ secrets.DOCKER_PORT }}
    user: ${{ secrets.DOCKER_USER }}
    pass: ${{ secrets.DOCKER_PASS }}
    file: 'docker-compose-swarm.yaml'
    name: 'stack-name'

Examples

Simple Example

name: 'Test Docker Stack Deploy'

on:
  push:

jobs:
  deploy:
    name: 'Deploy'
    runs-on: ubuntu-latest
    timeout-minutes: 5

    steps:
      - name: 'Checkout'
        uses: actions/checkout@v4

      - name: 'Docker Stack Deploy'
        uses: cssnr/stack-deploy-action@v1
        with:
          host: ${{ secrets.DOCKER_HOST }}
          port: ${{ secrets.DOCKER_PORT }}
          user: ${{ secrets.DOCKER_USER }}
          pass: ${{ secrets.DOCKER_PASS }}
          file: 'docker-compose-swarm.yaml'
          name: 'stack-name'

Full Example

name: 'Test Docker Stack Deploy'

on:
  workflow_dispatch:
    inputs:
      tags:
        description: 'Tags: comma,separated'
        required: true
        default: 'latest'

env:
  REGISTRY: 'ghcr.io'

jobs:
  deploy:
    name: 'Deploy'
    runs-on: ubuntu-latest
    timeout-minutes: 5

    steps:
      - name: 'Checkout'
        uses: actions/checkout@v4

      - name: 'Generate Tags'
        id: tags
        uses: smashedr/docker-tags-action@master
        with:
          images: '$${{ env.REGISTRY }}/${{ github.repository }}'
          extra: ${{ inputs.tags }}

      - name: 'Setup Buildx'
        uses: docker/setup-buildx-action@v2
        with:
          platforms: linux/amd64,linux/arm64

      - name: 'Docker Login'
        uses: docker/login-action@v2
        with:
          registry: $${{ env.REGISTRY }}
          username: ${{ secrets.GHCR_USER }}
          password: ${{ secrets.GHCR_PASS }}

      - name: 'Build and Push'
        uses: docker/build-push-action@v4
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: ${{ steps.tags.outputs.tags }}

      - name: 'Docker Stack Deploy'
        uses: cssnr/stack-deploy-action@v1
        with:
          host: ${{ secrets.DOCKER_HOST }}
          port: ${{ secrets.DOCKER_PORT }}
          user: ${{ secrets.DOCKER_USER }}
          ssh_key: '${{ secrets.DOCKER_SSH_KEY }}'
          file: 'docker-compose-swarm.yaml'
          name: 'stack-name'

Support

For general help or to request a feature see:

If you are experiencing an issue/bug or getting unexpected results you can:

Contributing

Currently, the best way to contribute to this project is to star this project on GitHub.

Additionally, you can support other GitHub Actions I have published:

For a full list of current projects to support visit: https://cssnr.github.io/