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 psMake 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
- Configure SSH using keyfile or password: src/ssh.sh
- Creates and uses a remote docker context: src/context.sh
- Option to run Docker login for any registry: src/login.sh
- Clean up the authorized_keys file for password: src/cleanup.sh
Don't see your feature here? Please help by submitting a Feature Request.
| 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.
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.
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.
Only set these to run docker login.
This can also be run manually in another step.
To run docker login on another registry. Requires both registry_user/registry_pass.
Example: ghcr.io.
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.
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-nameFor more examples, you can check out other projects using this action:
https://github.com/cssnr/docker-context-action/network/dependents
The following rolling tags are maintained.
| Version Tag | Rolling | Bugs | Feat. | Name | Target | Example |
|---|---|---|---|---|---|---|
| ✅ | ✅ | ✅ | Major | vN.x.x |
vN |
|
| ✅ | ✅ | ❌ | Minor | vN.N.x |
vN.N |
|
| ❌ | ❌ | ❌ | 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.
For general help or to request a feature, see:
- Q&A Discussion: https://github.com/cssnr/docker-context-action/discussions/categories/q-a
- Request a Feature: https://github.com/cssnr/docker-context-action/discussions/categories/feature-requests
If you are experiencing an issue/bug or getting unexpected results, you can:
- Report an Issue: https://github.com/cssnr/docker-context-action/issues
- Chat with us on Discord: https://discord.gg/wXy6m2X8wY
- Provide General Feedback: https://cssnr.github.io/feedback/
For more information, see the CSSNR SUPPORT.md.
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:
- Stack Deploy Action
- Portainer Stack Deploy Action
- Docker Context Action
- VirusTotal Action
- Mirror Repository Action
- Update Version Tags Action
- Docker Tags Action
- Update JSON Value Action
- JSON Key Value Check Action
- Parse Issue Form Action
- Cloudflare Purge Cache Action
- Mozilla Addon Update Action
- Package Changelog Action
- NPM Outdated Check Action
- Label Creator Action
- Algolia Crawler Action
- Upload Release Action
- Check Build Action
- Web Request Action
- Get Commit Action
❔ Unpublished Actions
These actions are not published on the Marketplace, but may be useful.
- cssnr/draft-release-action - Keep a draft release ready to publish.
- cssnr/env-json-action - Convert env file to json or vice versa.
- cssnr/push-artifacts-action - Sync files to a remote host with rsync.
- smashedr/update-release-notes-action - Update release notes.
- smashedr/combine-release-notes-action - Combine release notes.
📝 Template Actions
These are basic action templates that I use for creating new actions.
- js-test-action - JavaScript
- py-test-action - Python
- ts-test-action - TypeScript
- docker-test-action - Docker Image
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/