8000 Adding ability to prefix environment variables by benlei · Pull Request #55 · falti/dotenv-action · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Adding ability to prefix environment variables #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ jobs:
exit 1
fi

# test environment variables are prefixed
test-export-prefix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
path: ./fixtures/.env
export-variables: true
export-variables-prefix: "TFVARS_"
- run: |
if [ "$TFVARS_fixtures_1" != "123" ]; then
echo "Variables not exported"
exit 1
fi

test-keys-lowercase:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Mask values after reading from the `.env` file.

Export values as environment variables in addition to storing them in the output after reading from the `.env` file.

### `export-variables-prefix`

Prefix to prepend to each environment variable name when `export-variables` is set to true.

### `keys-case`

Transform keys cases to `lower`, `upper` or keep as it is with `bypass`.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
description: "whether to export the variables to the environment or not"
required: false
default: "false"
export-variables-prefix:
description: "prefix to add to the exported variables"
required: false
default: ""
keys-case:
description: "Transform keys case to lower, upper or keep as it is with bypass"
required: false
Expand Down
Binary file modified dist/index.js.cache
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/index.js.cache.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ try {
core.getInput("mask-variables").toLowerCase() === "true";
const exportVariables =
core.getInput("export-variables").toLowerCase() === "true";
const exportVariablesPrefix = core.getInput("export-variables-prefix");
const keysCase = core
.getInput("keys-case", { required: false })
.toLowerCase();
Expand Down Expand Up @@ -34,7 +35,7 @@ try {
core.setOutput(key, value);

if (exportVariables) {
core.exportVariable(key, value);
core.exportVariable(exportVariablesPrefix + key, value);
}
}
} catch (error) {
Expand Down
0