Skip to content

cssnr/docker-context-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Tag Major GitHub Tag Minor GitHub Release Version GitHub Dist Size Workflow Release Workflow Test Workflow Lint Quality Gate Status GitHub Last Commit Codeberg Last Commit GitHub Contributors GitHub Repo Size GitHub Top Language GitHub Discussions GitHub Forks GitHub Repo Stars GitHub Org Stars Discord Ko-fi

Docker SSH Context Action

Set up a Remote Docker Context over SSH using Password or Keyfile Authentication.
This allows all subsequent docker commands to run on the remote host (context).

steps:
  - name: 'Docker Context'
    uses: cssnr/docker-context-action@v1
    with:
      host: ${{ secrets.DOCKER_HOST }}
      user: ${{ secrets.DOCKER_USER }}
      port: 22 # 22 is the default value - optional
      pass: ${{ secrets.DOCKER_PASS }} # or ssh_key - optional
      ssh_key: ${{ secrets.DOCKER_SSH_KEY }} # or pass - optional

  - name: 'Inspect Docker'
    runs: |
      docker context ls
      docker context inspect
      docker info
      docker ps

Make sure to review the Inputs.

Stack Deploy: If you only need to deploy a swarm or compose stack use: cssnr/stack-deploy-action
Portainer Users: You can deploy directly to Portainer with: cssnr/portainer-stack-deploy-action

Features

Don't see your feature here? Please help by submitting a Feature Request.

Inputs

Input Name Default Value Description of Input
host Required SSH Hostname or IP
user Required SSH Username
port 22 SSH Port
pass or ssh_key SSH Password
ssh_key or pass SSH Key File
registry_user - Registry Username
registry_pass - Registry Password
registry_host docker.io Registry Host
token github.token Personal Access Token

With all inputs (not all required).

- name: 'Docker Context'
  uses: cssnr/docker-context-action@v1
  with:
    host: ${{ secrets.DOCKER_HOST }}
    user: ${{ secrets.DOCKER_USER }}
    port: 22 # 22 is default, you can remove or change this
    pass: ${{ secrets.DOCKER_PASS }} # not needed with ssh_key
    ssh_key: ${{ secrets.DOCKER_SSH_KEY }} # not needed with pass
    registry_user: ${{ vars.GHCR_USER }}
    registry_pass: ${{ secrets.GHCR_PASS }}
    registry_host: 'ghcr.io'

Make sure to check out the Examples.


host

The hostname or IP address of the remote docker server.

If your hostname is behind a proxy like Cloudflare you will need to use the IP address.

pass/ssh_key

Required to set up the SSH the connection. Provide a pass or ssh_key but not both.

If this was done in a previous step, omit these values to skip this step.

registry_user/registry_pass

Only set these to run docker login.

This can also be run manually in another step.

registry_host

To run docker login on another registry. Requires both registry_user/registry_pass.

Example: ghcr.io.

token

The ${{ github.token }} / {{ secrets.GITHUB_TOKEN }} is automatically passed, there is no need to manually pass these!

This is only used to download the bin scripts from the GitHub API. You can pass a PAT from your secrets if the default token does not work.

Examples

Example workflow.

steps:
  - name: 'Docker Context'
    uses: cssnr/docker-context-action@v1
    with:
      host: ${{ secrets.DOCKER_HOST }}
      user: ${{ secrets.DOCKER_USER }}
      pass: ${{ secrets.DOCKER_PASS }}

  - name: 'Stack Deploy'
    runs: docker stack deploy -c docker-compose.yaml --detach=false stack-name

For more examples, you can check out other projects using this action:
https://github.com/cssnr/docker-context-action/network/dependents

Tags

The following rolling tags are maintained.

Version Tag Rolling Bugs Feat. Name Target Example
GitHub Tag Major Major vN.x.x vN
GitHub Tag Minor Minor vN.N.x vN.N
GitHub Release Micro vN.N.N vN.N.N

You can view the release notes for each version on the releases page.

The Major tag is recommended. It is the most up-to-date and always backwards compatible. Breaking changes would result in a Major version bump. At a minimum you should use a Minor tag.

Support

For general help or to request a feature, see:

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

For more information, see the CSSNR SUPPORT.md.

Contributing

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

For more information, see the CSSNR CONTRIBUTING.md.

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

❔ Unpublished Actions

These actions are not published on the Marketplace, but may be useful.


📝 Template Actions

These are basic action templates that I use for creating new actions.

Note: The docker-test-action builds, runs and pushes images to GitHub Container Registry.


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

About

Set up a Docker Remote Context over SSH using Password or Keyfile Authentication

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project