Skip to content

Reads a package.json file and returns the contents as environment variables.

Notifications You must be signed in to change notification settings

rexdefuror/read-package-json

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

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 "./".

About

Reads a package.json file and returns the contents as environment variables.

Resources

Stars

Watchers

Forks

Packages

No packages published