Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
layers

GitHub Action

Update Json File values

v1.0.0

Update Json File values

layers

Update Json File values

This GitHub Action edits any value in a json file to the provided values

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Update Json File values

uses: restackio/[email protected]

Learn more about this action in restackio/update-json-values-action

Choose a version

GitHub Action - Update JSON values

This GitHub Action replaces the provided values on a provided JSON file

Usage

Add this step in your workflow file

- name: Update json-values description
  uses: restack/[email protected]
  with:
    file: my-file.json
    values: "{'TEMPLATE_VALUE_TO_REPLACE': 'value_here', 'ANOTHER_VALUE_TO_REPLACE': 'value_here'}"

Input Variables

  • file: File name/path to edit. e.g package.json
  • values: Values to replace on the json: {'TEMPLATE_VALUE_TO_REPLACE': 'value_here', 'ANOTHER_VALUE_TO_REPLACE: 'value_here'}

Example - Updating package.json Version

name: Build and Release

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

env:
  GITHUB_TOKEN: ${{ github.token }}

jobs:
  build:
    name: Build and Release
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
    - uses: actions/checkout@v3
 
    - name: Update package.json version
      uses: restackio/[email protected]
      with:
        file: package.json
        values: "{\"TEMPLATE_VALUE_TO_REPLACE\": \"new value\"}"