Skip to content

Commit 0feea78

Browse files
committed
Add Remote Context and Update Examples
1 parent 5fa0012 commit 0feea78

File tree

10 files changed

+80
-46
lines changed

10 files changed

+80
-46
lines changed

docs/guides/features.md

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Features
22

33
Deploy a Docker [stack](https://docs.docker.com/reference/cli/docker/stack/deploy/) or [compose](https://docs.docker.com/reference/cli/docker/compose/up/) file, to a remote host over SSH,
4-
using a [remote context](https://docs.docker.com/engine/manage-resources/contexts/). This deploys the stack from the current workspace without copying files.
4+
using a [Remote Context](#remote-context). This deploys the stack from the current workspace without copying files.
55

66
- Deploy to Docker Swarm or Compose.
77
- Deploy over SSH using [keyfile](../docs/inputs.md#pass-ssh-key) or [password](../docs/inputs.md#pass-ssh-key).
8-
- Deploy from the current working directory.
8+
- Deploy from the current working [directory](#remote-context).
99
- Deploy from a private registry with [credentials](../docs/inputs.md#registry-user-registry-pass).
1010
- [Job Summary](#job-summary) with deployment output, including errors.
1111
- Supports multiple compose [files](../docs/inputs.md#file) and stack deployments.
@@ -19,59 +19,56 @@ You can [get started here](get-started.md) or view [workflow examples](examples.
1919
If you need more options, please [open a feature request](https://github.com/cssnr/stack-deploy-action/discussions/categories/feature-requests)
2020
:::
2121

22-
## Job Summary
22+
## Remote Context
2323

24-
Unless disabled, a Job Summary is generated to capture the command, output and errors.
24+
This action uses a [remote context](https://docs.docker.com/engine/manage-resources/contexts/)
25+
to deploy the stack on the remote host, from the current environment.
2526

26-
💡 _Click on the heading to expand/collapse the item._
27+
```shell
28+
docker context create remote --docker "host=ssh://user@host:port"
29+
docker context use remote
30+
```
2731

28-
::: details Successful Job Summary ✔️
32+
After this all the subsequent `docker` commands, such as `stack deploy` and `compose up` are executed on the remote context (host).
2933

30-
---
34+
This allows you to run any steps to prepare your stack for deployment, in the workflow steps directly, without needing to copy any files.
3135

32-
🚀 Swarm Stack `test_stack-deploy` Successfully Deployed.
36+
::: details View workflow steps example
3337

34-
```text
35-
docker stack deploy -c docker-compose.yaml --detach=false --resolve-image=changed test_stack-deploy
36-
```
38+
```yaml
39+
steps:
40+
- name: 'Checkout'
41+
uses: actions/checkout@v5
3742

38-
<details><summary>Results</summary>
39-
40-
```text
41-
Updating service test_stack-deploy_alpine (id: tdk8v42m0rvp9hz4rbfrtszb6)
42-
1/1:
43-
overall progress: 0 out of 1 tasks
44-
overall progress: 1 out of 1 tasks
45-
verify: Waiting 5 seconds to verify that tasks are stable...
46-
verify: Waiting 4 seconds to verify that tasks are stable...
47-
verify: Waiting 3 seconds to verify that tasks are stable...
48-
verify: Waiting 2 seconds to verify that tasks are stable...
49-
verify: Waiting 1 seconds to verify that tasks are stable...
50-
verify: Service tdk8v42m0rvp9hz4rbfrtszb6 converged
51-
```
43+
# Add Steps to Prepare Your Stack File or Environment...
5244

53-
</details>
45+
- name: 'Stack Deploy'
46+
uses: cssnr/stack-deploy-action@v1
47+
with:
48+
# inputs excluded
49+
```
5450

5551
:::
5652

57-
::: details Failure Job Summary ❌
53+
## Job Summary
54+
55+
Unless disabled, a Job Summary is generated to capture the command, output and errors.
56+
57+
💡 _Click on the heading to expand/collapse the item._
58+
59+
::: details Successful Job Summary ✔️
5860

5961
---
6062

61-
⛔ Swarm Stack `test_stack-deploy` Failed to Deploy!
63+
<!--@include: ./include/summary-success.md-->
6264

63-
```text
64-
docker stack deploy -c docker-compose.yaml --detach=false --resolve-image=changed test_stack-deploy
65-
```
65+
:::
6666

67-
<details open><summary>Errors</summary>
67+
::: details Failure Job Summary ❌
6868

69-
```text
70-
Creating network test_stack-deploy_default
71-
failed to create network test_stack-deploy_default: Error response from daemon: network with name test_stack-deploy_default already exists
72-
```
69+
---
7370

74-
</details>
71+
<!--@include: ./include/summary-failed.md-->
7572

7673
:::
7774

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
⛔ Swarm Stack `test_stack-deploy` Failed to Deploy!
2+
3+
```text
4+
docker stack deploy -c docker-compose.yaml --detach=false --resolve-image=changed test_stack-deploy
5+
```
6+
7+
<details open><summary>Errors</summary>
8+
9+
```text
10+
Creating network test_stack-deploy_default
11+
failed to create network test_stack-deploy_default: Error response from daemon: network with name test_stack-deploy_default already exists
12+
```
13+
14+
</details>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
🚀 Swarm Stack `test_stack-deploy` Successfully Deployed.
2+
3+
```text
4+
docker stack deploy -c docker-compose.yaml --detach=false --resolve-image=changed test_stack-deploy
5+
```
6+
7+
<details><summary>Results</summary>
8+
9+
```text
10+
Updating service test_stack-deploy_alpine (id: tdk8v42m0rvp9hz4rbfrtszb6)
11+
1/1:
12+
overall progress: 0 out of 1 tasks
13+
overall progress: 1 out of 1 tasks
14+
verify: Waiting 5 seconds to verify that tasks are stable...
15+
verify: Waiting 4 seconds to verify that tasks are stable...
16+
verify: Waiting 3 seconds to verify that tasks are stable...
17+
verify: Waiting 2 seconds to verify that tasks are stable...
18+
verify: Waiting 1 seconds to verify that tasks are stable...
19+
verify: Service tdk8v42m0rvp9hz4rbfrtszb6 converged
20+
```
21+
22+
</details>

docs/guides/resources.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ A collection of resources and guides for getting started.
1313
&nbsp;
1414

1515
::: tip
16-
Have a related resource? Let us know by creating a [PR](https://github.com/cssnr/stack-deploy-docs/edit/master/docs/guides/examples.md) or an [Issue](https://github.com/cssnr/stack-deploy-docs/issues).
16+
Have a related resource? Let us know by creating a [PR](https://github.com/cssnr/stack-deploy-docs/edit/master/docs/guides/examples.md)
17+
or an [Issue](https://github.com/cssnr/stack-deploy-docs/issues) on [GitHub](https://github.com/cssnr/stack-deploy-docs).
1718
:::

docs/snippets/basic/step.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
with:
44
name: "stack-name" # set to your stack name
55
file: "docker-compose.yaml" # set to your compose file
6+
mode: "swarm" # if not using swarm set to "compose"
67
host: ${{ secrets.DOCKER_HOST }}
78
user: ${{ secrets.DOCKER_USER }}
89
port: 22 # 22 is default, you can remove or change this
910
pass: ${{ secrets.DOCKER_PASS }} # not needed with ssh_key
1011
ssh_key: ${{ secrets.DOCKER_SSH_KEY }} # not needed with pass
11-
mode: swarm # if not using swarm set to: compose

docs/snippets/basic/workflow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
with:
2020
name: "stack-name" # set to your stack name
2121
file: "docker-compose.yaml" # set to your compose file
22+
mode: "swarm" # if not using swarm set to "compose"
2223
host: ${{ secrets.DOCKER_HOST }}
2324
user: ${{ secrets.DOCKER_USER }}
2425
port: 22 # 22 is default, you can remove or change this
2526
pass: ${{ secrets.DOCKER_PASS }} # not needed with ssh_key
2627
ssh_key: ${{ secrets.DOCKER_SSH_KEY }} # not needed with pass
27-
mode: swarm # if not using swarm set to: compose

docs/snippets/examples/compose/basic.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
with:
44
name: "stack-name"
55
file: "docker-compose.yaml"
6+
mode: "compose"
67
host: ${{ secrets.DOCKER_HOST }}
78
user: ${{ secrets.DOCKER_USER }}
89
pass: ${{ secrets.DOCKER_PASS }} # not needed with ssh_key
910
ssh_key: ${{ secrets.DOCKER_SSH_KEY }} # not needed with pass
10-
mode: compose

docs/snippets/examples/compose/full.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
with:
44
name: "stack-name"
55
file: "docker-compose.yaml"
6+
mode: "compose"
67
host: ${{ secrets.DOCKER_HOST }}
78
user: ${{ secrets.DOCKER_USER }}
89
port: 22 # 22 is default, you can remove or change this
@@ -12,6 +13,5 @@
1213
registry_host: "ghcr.io"
1314
registry_user: ${{ vars.GHCR_USER }}
1415
registry_pass: ${{ secrets.GHCR_PASS }}
15-
mode: compose
16-
args: --remove-orphans --force-recreate
16+
args: "--remove-orphans --force-recreate"
1717
summary: true

docs/snippets/examples/compose/options.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
with:
44
name: "stack-name"
55
file: "docker-compose.yaml"
6+
mode: "compose"
67
host: ${{ secrets.DOCKER_HOST }}
78
user: ${{ secrets.DOCKER_USER }}
89
pass: ${{ secrets.DOCKER_PASS }} # not needed with ssh_key
910
ssh_key: ${{ secrets.DOCKER_SSH_KEY }} # not needed with pass
10-
mode: compose
11-
args: --remove-orphans --force-recreate
11+
args: "--remove-orphans --force-recreate"

docs/snippets/examples/compose/registry.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
with:
44
name: "stack-name"
55
file: "docker-compose.yaml"
6+
mode: "compose"
67
host: ${{ secrets.DOCKER_HOST }}
78
user: ${{ secrets.DOCKER_USER }}
89
pass: ${{ secrets.DOCKER_PASS }} # not needed with ssh_key
910
ssh_key: ${{ secrets.DOCKER_SSH_KEY }} # not needed with pass
1011
registry_host: "ghcr.io"
1112
registry_user: ${{ vars.GHCR_USER }}
1213
registry_pass: ${{ secrets.GHCR_PASS }}
13-
mode: compose

0 commit comments

Comments
 (0)