Skip to content

cssnr/update-json-value-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Tags Test Quality Gate Status GitHub Release Version GitHub Last Commit Codeberg Last Commit GitHub Top Language GitHub Org Stars Discord

Update JSON Value Action

Update JSON file Value(s) for Publishing.

Zero configuration action to update a manifest.json file version value to a release tag. Allows setting multiple key/value pairs and setting nested keys. Currently only supports string values.

Note

Please submit a Feature Request for new features or Open an Issue if you find any bugs.

Inputs

input required default description
file No manifest.json JSON File Path
keys No version JSON Keys to Update, One per Line
values No $GITHUB_REF_NAME Values to Update, One per Line
write No true Write Updates to file
seperator No . Nested Key Seperator

If no options are passed, it will update the manifest.json file's key version to the value of GITHUB_REF_NAME.
For multiple keys and values use new lines with a yaml |.

- name: 'Update JSON'
  uses: cssnr/update-json-value-action@v1

Outputs

output description
result Updated JSON String
- name: 'Update JSON'
  id: json
  uses: cssnr/update-json-value-action@v1

- name: 'Echo Result'
  run: echo '${{ steps.json.outputs.result }}'

Examples

Same as above but manually setting values and only running on release events.

- name: 'Update JSON'
  uses: cssnr/update-json-value-action@v1
  if: ${{ github.event_name == 'release' }}
  with:
      file: manifest.json
      keys: version
      values: ${{ github.ref_name }}

Same as above but also setting an additional key value pair.

- name: 'Update JSON'
  uses: cssnr/update-json-value-action@v1
  if: ${{ github.event_name == 'release' }}
  with:
      file: manifest.json
      keys: |
          version
          version_name
      values: |
          ${{ github.ref_name }}
          "Release ${{ github.ref_name }}"

Set a nested key and use file from different directory.

- name: 'Update JSON'
  uses: cssnr/update-json-value-action@v1
  if: ${{ github.event_name == 'release' }}
  with:
      file: src/manifest.json
      keys: |
          meta.version
      values: |
          "Release ${{ github.ref_name }}"

Support

For general help or to request a feature, see:

If you are experiencing an issue/bug or getting unexpected results, you can:

Contributing

Currently, the best way to contribute to this project is to star this project on GitHub.

Additionally, you can support other GitHub Actions I have published:

For a full list of current projects to support visit: https://cssnr.github.io/