Skip to content
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

Fail if key is empty #39

Merged
merged 2 commits into from
Feb 15, 2022
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
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,37 @@ jobs:
then
echo "ERR"
fi

should-fail-test-absolute-path:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Create folder
run: |
mkdir -p subdir

- name: Make envfile
uses: ./
with:
envkey_DEBUG: false
directory: /home


should-fail-test-bad-secret:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Create folder
run: |
mkdir -p subdir

- name: Make envfile
uses: ./
with:
envkey_SECRET_KEY: ${{ secrets.NON_EXISTENT_SECRET }}
8 changes: 7 additions & 1 deletion src/create-envfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
# Make sure the env keys are sorted to have reproducible output
for key in sorted(env_keys):
if key.startswith("INPUT_ENVKEY_"):
out_file += "{}={}\n".format(key.split("INPUT_ENVKEY_")[1], os.getenv(key))
value = os.getenv(key, "")

# If the key is empty, throw an error.
if value == "":
raise Exception(f"Empty env key found: {key}")

out_file += "{}={}\n".format(key.split("INPUT_ENVKEY_")[1], value)

# get directory name in which we want to create .env file
directory = str(os.getenv("INPUT_DIRECTORY", ""))
Expand Down