Skip to content

Commit 1de4f57

Browse files
authored
Update for env_data (#11)
1 parent 0f7917d commit 1de4f57

9 files changed

Lines changed: 65 additions & 41 deletions

File tree

docs/docs/inputs.md

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ pageClass: inputs-page
99

1010
| Input Name | Default Input Value | Short Description of Input |
1111
| :------------------------------- | :---------------------------- | :---------------------------------------- |
12-
| [name](#name) **\*** <CB /> | - | Stack Name |
13-
| [url](#url) **\*** <CB /> | - | Portainer URL |
14-
| [token](#token) **\*** <CB /> | - | Portainer Token |
12+
| [name](#name) **\*** <CB /> | _Required_ | Stack Name |
13+
| [url](#url) **\*** <CB /> | _Required_ | Portainer URL |
14+
| [token](#token) **\*** <CB /> | _Required_ | Portainer Token |
1515
| [file](#file) <CB /> | `docker-compose.yaml` | Compose File |
1616
| [endpoint](#endpoint) <CB /> | `endpoints[0].Id` | Portainer Endpoint |
1717
| [ref](#ref) <CB /> | `current reference` | Repository Ref |
@@ -21,13 +21,14 @@ pageClass: inputs-page
2121
| [pull](#pull) <CB /> | `true` | Pull Images |
2222
| [type](#type) <CB /> | `repo` | Type [`repo`, `file`] |
2323
| [standalone](#standalone) <CB /> | `false` | Deploy Standalone Stack |
24-
| [env_json](#env_json) <CB /> | - | Dotenv JSON Data |
24+
| [env_data](#env_data) <CB /> | - | Dotenv JSON Data |
25+
| [env_json](#env_data) <CB /> | **DEPRECATED** | Use [env_data](#env_data) |
2526
| [env_file](#env_file) <CB /> | - | Dotenv File Path |
2627
| [merge_env](#merge_env) <CB /> | `false` | Merge Env Vars |
2728
| [username](#username) <CB /> | - | Repository Username |
2829
| [password](#password) <CB /> | - | Repository Password |
29-
| [headers](#headers) <CB /> | `"{}"` | Custom Headers JSON |
3030
| [fs_path](#fs_path) **¹** <CB /> | - | Relative Path (BE) |
31+
| [headers](#headers) <CB /> | `"{}"` | Custom Headers JSON |
3132
| [summary](#summary) <CB /> | `true` | Add Summary to Job |
3233

3334
> **\* Required**
@@ -78,7 +79,7 @@ Default: `${endpoints[0]}`
7879

7980
This defaults to the reference that triggered the workflow.
8081

81-
If deploying from a different repository than the current one, you may want to specify the `ref` of that repository to deploy from.
82+
If deploying from a different [repo](#repo) than the current one, you may want to specify the `ref` of that repository to deploy from.
8283

8384
Example: `refs/heads/master`
8485

@@ -90,6 +91,8 @@ This defaults to the repository running the action.
9091

9192
If you want to deploy a different repository, put the full http URL to that repository.
9293

94+
Note: you probably also want to specify the [ref](#ref) from that repository to use.
95+
9396
Example: `https://github.com/cssnr/portainer-stack-deploy-action`
9497

9598
Default: <span v-pre>`${{ github.server_url }}/${{ github.repository }}`</span>
@@ -122,28 +125,35 @@ Default: `repo`
122125

123126
### standalone <CB />
124127

125-
Deploy a **compose** stack instead of _swarm_.
126-
Set to `true` to enable.
128+
Deploy a **compose** stack instead of _swarm_. Set to `true` to enable.
127129

128130
Default: `false`
129131

130-
### env_json <CB /> {#env_json}
132+
### env_data <CB /> {#env_data}
131133

132134
Optional environment variables used when creating the stack.
133-
File should be in dotenv format and JSON should be an object. Example: {"KEY": "Value"}
134135

135-
This can be used with [env_file](#env_file). Values in [env_file](#env_file) take precedence over these values.
136+
These can be provided in JSON or YAML format and can be used with [env_file](#env_file).
137+
Values in [env_file](#env_file) take precedence over these values.
136138

137-
::: details View JSON Input Examples
139+
::: details View JSON/YAML Input Examples
138140

139141
These examples are identical, just different ways of passing the input.
140142

141143
::: code-group
142144

145+
```yaml [YAML]
146+
- uses: cssnr/portainer-stack-deploy-action@v1
147+
with:
148+
env_data: |
149+
KEY: Value
150+
KEY_2: Value 2
151+
```
152+
143153
```yaml [Multi-Line JSON]
144154
- uses: cssnr/portainer-stack-deploy-action@v1
145155
with:
146-
env_json: |
156+
env_data: |
147157
{
148158
"KEY": "Value",
149159
"KEY_2": "Value 2"
@@ -153,7 +163,7 @@ These examples are identical, just different ways of passing the input.
153163
```yaml [Single Line JSON]
154164
- uses: cssnr/portainer-stack-deploy-action@v1
155165
with:
156-
env_json: '{"KEY": "Value", "KEY_2": "Value 2"}'
166+
env_data: '{"KEY": "Value", "KEY_2": "Value 2"}'
157167
```
158168
159169
Note: Additional [inputs](../docs/inputs.md) are excluded for brevity.
@@ -162,16 +172,16 @@ Note: Additional [inputs](../docs/inputs.md) are excluded for brevity.
162172
163173
::: warning
164174
Inputs are NOT secure unless using secrets or secure output (masked).
165-
Using `env_json` on a public repository will otherwise expose this data in the actions' logs.
166-
For an example of an action that produces secure out for use with `env_json` see the [hashicorp/vault-action example](../guides/examples.md#multi-step).
175+
Using `env_data` on a public repository will otherwise expose this data in the actions' logs.
176+
For an example of an action that produces secure out for use with `env_data` see the [hashicorp/vault-action example](../guides/examples.md#multi-step).
167177
To securely pass unmasked values, use the [env_file](#env_file) option.
168178
:::
169179

170180
### env_file <CB /> {#env_file}
171181

172182
Environment File in [dotenv](https://www.npmjs.com/package/dotenv) format, parsed using [dotenv](https://www.npmjs.com/package/dotenv).
173183

174-
This can be used with [env_json](#env_json). Values in this file take precedence over [env_json](#env_json).
184+
This can be used with [env_data](#env_data). Values in this file take precedence over [env_data](#env_data).
175185

176186
::: details View Environment File Input Example
177187

@@ -194,9 +204,9 @@ Note: Additional [inputs](../docs/inputs.md) are excluded for brevity.
194204
### merge_env <CB /> {#merge_env}
195205

196206
Set this to `true` to merge the current environment variables from the existing stack
197-
with any newly provided variables in the [env_json](#env_json) or [env_file](#env_file) inputs.
207+
with any newly provided variables in the [env_data](#env_data) or [env_file](#env_file) inputs.
198208

199-
When not providing the [env_json](#env_json) or [env_file](#env_file) inputs the
209+
When not providing the [env_data](#env_data) or [env_file](#env_file) inputs the
200210
current environment variables from the existing stack are always used.
201211

202212
When deploying a new stack, there are no current environment variables to merge, and this has no effect.
@@ -215,41 +225,55 @@ Password for private repository authentication when [type](#type) is set to `rep
215225

216226
This is **NOT** your Portainer password, see [token](#token) for Portainer authentication.
217227

228+
### fs_path <CB /> <Badge type="tip" text="Business Edition" /> {#fs_path}
229+
230+
Relative Path Support for Portainer BE.
231+
Set this to enable relative path volumes support for volume mappings in your compose file.
232+
233+
_For more info see the [Portainer Documentation - Relative Path Support](https://docs.portainer.io/advanced/relative-paths)._
234+
218235
### headers <CB />
219236

220-
Custom Headers in **JSON** format for services like Cloudflare Zero Trust.
237+
Custom Headers in JSON or YAML format for services like Cloudflare Zero Trust.
221238

222-
The `headers` are parsed with JSON.parse and passed directly to axios:
239+
The `headers` are parsed with `JSON.parse` or `yaml.load` and passed directly to axios.
223240

224241
```javascript
225242
headers: { 'X-API-Key': token, ...JSON.parse(headers) }
226243
```
227244

228245
::: details View Headers Input Example
229246

230-
```yaml
247+
::: code-group
248+
249+
```yaml [YAML]
231250
- uses: cssnr/portainer-stack-deploy-action@v1
232251
with:
233-
headers: |
252+
env_data: |
253+
CF-Access-Client-Id: ${{ secrets.CF_CLIENT_ID }}
254+
CF-Access-Client-Secret: ${{ secrets.CF_CLIENT_SECRET }}
255+
```
256+
257+
```yaml [Multi-Line JSON]
258+
- uses: cssnr/portainer-stack-deploy-action@v1
259+
with:
260+
env_data: |
234261
{
235262
"CF-Access-Client-Id": "${{ secrets.CF_CLIENT_ID }}",
236263
"CF-Access-Client-Secret": "${{ secrets.CF_CLIENT_SECRET }}"
237264
}
238265
```
239266

267+
```yaml [toJSON Output]
268+
- uses: cssnr/portainer-stack-deploy-action@v1
269+
with:
270+
env_data: ${{ toJSON(steps.import-secrets.outputs) }}
271+
```
272+
240273
Note: Additional [inputs](../docs/inputs.md) are excluded for brevity.
241274

242275
:::
243276

244-
Default: `"{}"`
245-
246-
### fs_path <CB /> <Badge type="tip" text="Business Edition" /> {#fs_path}
247-
248-
Relative Path Support for Portainer BE.
249-
Set this to enable relative path volumes support for volume mappings in your compose file.
250-
251-
_For more info see the [Portainer Documentation - Relative Path Support](https://docs.portainer.io/advanced/relative-paths)._
252-
253277
### summary <CB />
254278

255279
Write a Summary for the job. To disable this set to `false`.

docs/guides/features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and [Business Enterprise Edition](https://www.portainer.io/solutions/portainer-f
77
- Deploy or re-deploy an existing stack otherwise create a new stack.
88
- Deploy from a repository or a compose file, see [type](../docs/inputs.md#type).
99
- Deploy from a different [repo](../docs/inputs.md#repo) than the current one.
10-
- Provide environment variables in [JSON](../docs/inputs.md#env_json) or [file](../docs/inputs.md#env_file) format.
10+
- Provide environment variables in [JSON/YAML](../docs/inputs.md#env_data) or [file](../docs/inputs.md#env_file) format.
1111
- Automatically parse [Endpoint ID](../docs/inputs.md#endpoint) if only one endpoint.
1212
- Supports Docker Swarm and Docker [Standalone](../docs/inputs.md#standalone).
1313
- Supports custom [headers](../docs/inputs#headers) for services like Cloudflare Zero Trust.

docs/guides/get-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ You only need to set the [name](../docs/inputs.md#name), [url](../docs/inputs.md
4444
The compose [file](../docs/inputs.md#file) path is relative to your working directory.
4545
If you check out your repository to the root and your compose file is in the `app` directory, set [file](../docs/inputs.md#file) to: `app/docker-compose.yaml`
4646

47-
You can provide environment variables from either a file or JSON.
48-
If providing secrets via [env_json](../docs/inputs.md#env_json) they should come from secure input (masked).
47+
You can provide environment variables from either a file or JSON/YAML.
48+
If providing secrets via [env_data](../docs/inputs.md#env_data) they should come from secure input (masked).
4949

5050
<div class="tip custom-block" style="padding-top: 8px">
5151

docs/snippets/examples/multi/tojson.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
file: "docker-compose.yaml"
1818
url: ${{ secrets.PORTAINER_URL }}
1919
token: ${{ secrets.PORTAINER_TOKEN }}
20-
env_json: ${{ toJSON(steps.import-secrets.outputs) }}
20+
env_data: ${{ toJSON(steps.import-secrets.outputs) }}

docs/snippets/examples/steps/env.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
file: "docker-compose.yaml"
66
url: ${{ secrets.PORTAINER_URL }}
77
token: ${{ secrets.PORTAINER_TOKEN }}
8-
env_json: '{"KEY": "Value"}'
8+
env_data: '{"KEY": "Value"}'
99
env_file: .env

docs/snippets/examples/steps/json.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
file: "docker-compose.yaml"
66
url: ${{ secrets.PORTAINER_URL }}
77
token: ${{ secrets.PORTAINER_TOKEN }}
8-
env_json: |
8+
env_data: |
99
{
1010
"APP_PRIVATE_KEY": "${{ secrets.APP_PRIVATE_KEY }}",
1111
"VERSION": "${{ inputs.VERSION }}"

docs/snippets/examples/steps/merge-env.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
file: "docker-compose.yaml"
66
url: ${{ secrets.PORTAINER_URL }}
77
token: ${{ secrets.PORTAINER_TOKEN }}
8-
env_json: '{"KEY": "Value"}'
8+
env_data: '{"KEY": "Value"}'
99
merge_env: true

docs/snippets/examples/workflows/full.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
name: ${{ env.stack-name }}
104104
username: ${{ vars.GHCR_USER }}
105105
password: ${{ secrets.GHCR_PASS }}
106-
env_json: |
106+
env_data: |
107107
{
108108
"VERSION": "$${{ github.ref_name }}",
109109
"STACK_NAME": "${{ env.stack-name }}",

docs/snippets/examples/workflows/workflow-run.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
name: ${{ env.stack-name }}
4646
username: ${{ vars.GHCR_USER }}
4747
password: ${{ secrets.GHCR_PASS }}
48-
env_json: |
48+
env_data: |
4949
{
5050
"VERSION": "${{ env.version == 'master' && 'latest' || env.version }}",
5151
"STACK_NAME": "${{ env.stack-name }}",

0 commit comments

Comments
 (0)