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

JSON is all uppercase #2

Open
ylupien opened this issue Jul 22, 2020 · 6 comments
Open

JSON is all uppercase #2

ylupien opened this issue Jul 22, 2020 · 6 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ylupien
Copy link

ylupien commented Jul 22, 2020

Hi !

Look like I have an case issue with this github action. I specified lower case in the configuration and the generated file is in uppercase.

      - name: Write hg-version.json
        uses: schdck/create-env-json@v2
        id: create-env
        with:
          file-name: './public/hg-version.json'
          version: ${{ github.sha }}
          test: '123'
{"VERSION":"695927bb3fa6176ae36ccb2216aa53dc85b5b542","TEST":"123"}

Any recommendation ?

@SouthernYoda
Copy link

I encountered the same issue.

@ylupien have you managed to find a resolution for this?

@schdck
Copy link
Owner

schdck commented Aug 27, 2020

Hey @ylupien @SouthernYoda, sorry for the delay. I've taken a quick look into the code but haven't managed to identify what's causing this behavior. Fixing this would require some debugging, which I don't currently have the time to do. I'll take a look into it as soon as I can, but in the mean time, feel free to take a look and submit a PR if you guys find anything

@schdck schdck added bug Something isn't working help wanted Extra attention is needed labels Aug 27, 2020
@SouthernYoda
Copy link

This appears to be a limitation of using GitHub inputs in this way, the input keys are automatically converted to uppercase as described in the documentation for GitHub inputs. It's too bad because I really like how you specified the inputs.

"When you specify an input to an action in a workflow file or use a default input value, GitHub creates an environment variable for the input with the name INPUT_<VARIABLE_NAME>. The environment variable created converts input names to uppercase letters and replaces spaces with _ characters." (https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs)

I've forked your repo and printed the "key" variable to console. The key value is already uppercase when it is read by the script.
image

A resolution might be to nest the input so the user enters in:

<arbitrary element name>: 
  key: <desired key>
  value: <value>
<arbitrary element name>:
  key: <desired key>
  value: <value>

Hope this helped, I don't have experience with node so this is as much help as I can provide for now.

@dotKuro
Copy link

dotKuro commented Jun 2, 2021

What about?:

json-content:
  - key: foo
    value: blub
  - key: bar
    value: buz

This would eliminate the unnecessary name for each element.

@metaben
Copy link

metaben commented Dec 3, 2021

A workaround is to follow this step with jacobtomlinson/gha-find-replace@v2 to overwrite the uppercase inside the json.

@andrew-fennell
Copy link

I just forked the repo and converted all keys to be lowercase. If anyone needs that specific functionality, you can find it here: https://github.com/andrew-fennell/create-env-json

If you need specific capitalization (not all lowercase or uppercase), such as "Key", the current release of this repo (v2) and my fork (v3) will not work for you.

I believe the underlying issue is how GitHub handles the inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants