8000 Support exporting as environment variables by F21 · Pull Request #43 · falti/dotenv-action · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support exporting as environment variables #43

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 2 commits into from
Feb 28, 2023
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
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
8000
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,17 @@ jobs:
- uses: ./
with:
path: ./fixtures/.env

test-export:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
path: ./fixtures/.env
export-variables: true
- run: |
if [ "$fixtures_1" != "123" ]; then
echo "Variables not exported"
exit 1
fi
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Log variables after reading from the `.env` file.

Mask values after reading from the `.env` file.

### `export-variables`

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

## Outputs

### `generic`
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ inputs:
description: 'whether to mask the variables as secrets or not'
required: false
default: 'false'
export-variables:
description: 'whether to export the variables to the environment or not'
required: false
default: 'false'
outputs:
generic: # output will be available to future steps
description: 'This command will have generic output variables based on .env'
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.

6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ try {
const logVariables = core.getInput('log-variables').toLowerCase() === 'true';
const maskVariables =
core.getInput('mask-variables').toLowerCase() === 'true';
const exportVariables =
core.getInput('export-variables').toLowerCase() === 'true';
const variables = dotenvAction(dotenvFile, logVariables);

if (maskVariables) {
Expand All @@ -27,6 +29,10 @@ try {
for (const key in variables) {
const value = variables[key];
core.setOutput(key, value);

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