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

GitHub Tag Major GitHub Tag Minor GitHub Release Version Release Test Lint Quality Gate Status GitHub Last Commit Codeberg Last Commit GitHub Top Language GitHub Org Stars Discord

Update JSON Value Action

Update JSON file Key Values for Building or 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 Req. Default Description
file - manifest.json JSON File Path
keys - version JSON Keys to Update *
values - $GITHUB_REF_NAME Values to Update *
write - true Write Updates to file
seperator - . Nested Key Seperator
summary - true Add Summary to Job *

keys/values - A newline delimited | list of keys/values to update, one per line. See Examples for more details.

summary - Write a Summary for the job. To disable this set to false.

To view a workflow run, click on a recent Test job (requires login).

👀 View Example Summary

💾 ✔️ package.json

Keys/Values
KeyValue
nametest
scripts.linttest
Results
{
  "name": "test",
  "scripts": {
    "build": "ncc build src/index.js",
    "build:watch": "npm run build -- --watch",
    "lint": "test"
  },
  "dependencies": {
    "@actions/core": "^1.11.1"
  },
  "devDependencies": {
    "@eslint/js": "^9.20.0",
    "@vercel/ncc": "^0.38.3",
    "eslint": "^9.20.1",
    "eslint-config-prettier": "^10.0.1",
    "eslint-plugin-prettier": "^5.2.3",
    "prettier": "^3.5.1"
  }
}
Inputs
InputValue
filepackage.json
keysname,scripts.lint
valuestest,test
writetrue
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

💡 Click on an example heading to expand or collapse the example.

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 }}
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 }}"

Tags

The following rolling tags are maintained.

Tag Example Target Bugs Feat. Description
GitHub Tag Major vN vN.x.x Includes new features but is always backwards compatible.
GitHub Tag Minor vN.N vN.N.x Only receives bug fixes. This is the most stable tag.
GitHub Release vN.N.N vN.N.N Not a rolling tag. Not recommended.

You can view the release notes for each version on the releases page.

Support

For general help or to request a feature, see:

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

For more information, see the CSSNR SUPPORT.md.

Contributing

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

For more information, see the CSSNR SUPPORT.md.

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

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