Skip to content
package

GitHub Action

Read package.json

v1.0.5 Latest version

Read package.json

package

Read package.json

GitHub Action that reads a package.json file (or any JSON with same properties 😁)

Installation

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

              

- name: Read package.json

uses: rexdefuror/[email protected]

Learn more about this action in rexdefuror/read-package-json

Choose a version

Build

Description

Reads a package.json file and returns the contents as environment variables. Naming convention depends on the file name. For example, if the file is named package.json, the environment variables will be prefixed with PACKAGE_. If the file is named testing.json, the environment variables will be prefixed with TESTING_.

Example Usage

- name: Package.json info
  uses: rexdefuror/[email protected]

- run: echo "name - ${{ env.PACKAGE_NAME }}"
- run: echo "version - ${{ env.PACKAGE_VERSION }}"
- run: echo "description - ${{ env.PACKAGE_DESCRIPTION }}"

Example with custom file name

- name: Package.json info
  uses: rexdefuror/[email protected]
  with:
    file: testing.json

- run: echo "name - ${{ env.TESTING_NAME }}"
- run: echo "version - ${{ env.TESTING_VERSION }}"
- run: echo "description - ${{ env.TESTING_DESCRIPTION }}"

Example with custom path

- name: Package.json info
  uses: rexdefuror/[email protected]
  with:
    file: testing.json
    path: ./src

- run: echo "name - ${{ env.TESTING_NAME }}"
- run: echo "version - ${{ env.TESTING_VERSION }}"
- run: echo "description - ${{ env.TESTING_DESCRIPTION }}"

Inputs

file

Optional The name of the file to read. Default "package.json".

path

Optional The path to the file. Default "./".