You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 790bd44
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+86-7Lines changed: 86 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,8 +37,9 @@ GitHub Action and Docker image used to deploy a Docker stack on a Docker Swarm.
37
37
|`prune`|`PRUNE`| Prune services that are not defined in the stack file ||**0**|
38
38
|`stack_file`|`STACK_FILE`| Path to the stack file used in the deploy. | ✅ ||
39
39
|`stack_name`|`STACK_NAME`| Name of the stack to be deployed. | ✅ ||
40
-
|`stack_param`|`STACK_PARAM`| Additional parameter (env var) to be passed to the stack. |||
41
-
|`env_file`|`ENV_FILE`| Additional environment variables to be passed to the stack. |||
40
+
|`stack_param`|`STACK_PARAM`| A single additional value, available to the stack file as `${STACK_PARAM}`. Superseded by `env_file`, see [Passing values into the stack file](#passing-values-into-the-stack-file). |||
41
+
|`env_file`|`ENV_FILE`| Additional environment variables **as content**, one `VAR=VALUE` per line. Mutually exclusive with `env_file_path`. |||
42
+
|`env_file_path`|`ENV_FILE_PATH`|**Path** to a file of additional environment variables, one `VAR=VALUE` per line. Mutually exclusive with `env_file`. |||
42
43
|`debug`|`DEBUG`| Verbose logging ||**0**|
43
44
|`scale_after`|`SCALE_AFTER`| Scale a service after a deployment has converged successfully. Example: servicename=1 |||
44
45
@@ -60,6 +61,85 @@ repository UI, and used to surface much later as an opaque
60
61
structural in a PEM key, and whitespace can be a legitimate part of a token.
61
62
62
63
64
+
## Passing values into the stack file
65
+
66
+
Your stack file can reference environment variables, and `docker stack deploy`
67
+
substitutes them as it reads the file. This action gives you three ways to set
68
+
those variables, all of which work through that same substitution.
69
+
70
+
### `env_file` — the variables themselves
71
+
72
+
Pass the content directly. Each line is a `VAR=VALUE` pair:
73
+
74
+
```yaml
75
+
- name: Deploy
76
+
uses: kitconcept/docker-stack-deploy@v1.4.0
77
+
with:
78
+
# ...
79
+
env_file: |
80
+
BACKEND_REPLICAS=2
81
+
FRONTEND_REPLICAS=3
82
+
SOLR_JAVA_MEM=-Xms1536m -Xmx1536m
83
+
```
84
+
85
+
```yaml
86
+
# stacks/plone.yml
87
+
services:
88
+
backend:
89
+
deploy:
90
+
replicas: ${BACKEND_REPLICAS}
91
+
frontend:
92
+
deploy:
93
+
replicas: ${FRONTEND_REPLICAS}
94
+
```
95
+
96
+
Values are taken **verbatim**, matching `docker --env-file`: a value may
97
+
contain spaces, and quotes around it become part of the value rather than
98
+
being stripped. So `GREETING="hello"` sets `GREETING` to `"hello"`, quotes
99
+
included.
100
+
101
+
Lines that are blank or start with `#` are ignored. Anything else that is not
102
+
`NAME=VALUE`is an error naming the offending line, rather than a silent
103
+
failure to export.
104
+
105
+
### `env_file_path` — a file to read them from
106
+
107
+
If the variables already live in a file in your repository, point at it
108
+
instead. Relative paths resolve against the workspace, the same as `stack_file`:
109
+
110
+
```yaml
111
+
with:
112
+
# ...
113
+
env_file_path: "stacks/production.env"
114
+
```
115
+
116
+
The file format and the verbatim semantics are identical to `env_file`. The two
117
+
inputs are mutually exclusive — supplying both is an error, because the
118
+
precedence between them would otherwise be arbitrary.
119
+
120
+
### `stack_param` — a single value (discouraged)
121
+
122
+
`stack_param` sets one variable, always named `STACK_PARAM`:
123
+
124
+
```yaml
125
+
with:
126
+
# ...
127
+
stack_param: "2"
128
+
```
129
+
130
+
```yaml
131
+
# stacks/plone.yml
132
+
services:
133
+
backend:
134
+
deploy:
135
+
replicas: ${STACK_PARAM}
136
+
```
137
+
138
+
It works, and it is kept for compatibility, but it is a one-variable special
139
+
case of `env_file` with a name you cannot choose. Prefer `env_file` or
140
+
`env_file_path`for anything new.
141
+
142
+
63
143
## Using the GitHub Action
64
144
65
145
Add, or edit an existing, `yaml` file inside `.github/actions` and use the configuration options listed above.
Documented how values reach the stack file, with worked examples for `env_file`, `env_file_path` and `stack_param`, and noted that `stack_param` is a one-variable special case of `env_file`. @ericof
Added an `env_file_path` input, which reads the additional environment variables from a file instead of taking them as content. `env_file` keeps its current meaning, so nothing breaks; supplying both is an error. @ericof
0 commit comments