https://github.com/byu-oit/github-action-package-json
Parses and outputs information from a package.json file
https://github.com/byu-oit/github-action-package-json
github-actions
Last synced: 3 months ago
JSON representation
Parses and outputs information from a package.json file
- Host: GitHub
- URL: https://github.com/byu-oit/github-action-package-json
- Owner: byu-oit
- License: apache-2.0
- Created: 2021-03-16T15:46:13.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-09-04T21:31:01.000Z (almost 3 years ago)
- Last Synced: 2025-09-30T23:02:14.348Z (10 months ago)
- Topics: github-actions
- Language: TypeScript
- Homepage:
- Size: 683 KB
- Stars: 0
- Watchers: 21
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GitHub Action Package JSON
Parses and outputs information from a package.json file
## Usage
```yaml
on: push
# ...
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Parse package.json version
id: package
uses: byu-oit/github-action-package-json@v2
with:
version: true
- name: Build and push docker image with version tags
env:
# set ECR_REGISTRY
# set ECR_REPO
VERSION_TAG: ${{ steps.package.outputs.version }}
MAJOR_TAG: ${{ steps.package.outputs.version_major }}
MINOR_TAG: ${{ steps.package.outputs.version_minor }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPO:$VERSION_TAG -t $ECR_REGISTRY/$ECR_REPO:v$MAJOR_TAG -t $ECR_REGISTRY/$ECR_REPO:v$MAJOR_TAG.$MINOR_TAG .
docker push $ECR_REGISTRY/$ECR_REPO --all-tags
```
## Inputs
| Name | Description | Default |
|:----------|:----------------------------------------------------------|:-------------------------------------------|
| directory | The working directory of the package.json file | Current working directory `process.cwd()` |
| version | Toggles the version module to output version information. | false |
## Outputs
All outputs are converted to `string` using `JSON.stringify` but can be
converted to their output types using the `fromJson` method.
| Name | Type | Description |
|:-------------------|:-------|:--------------------------------|
| version | string | The full semantic version |
| version_major | number | The major semantic version |
| version_minor | number | The minor semantic version |
| version_patch | number | The patch semantic version |
| version_build | string | The build semantic version |
| version_prerelease | string | The prerelease semantic version |
## Contributing
This package only parses and exposes information from the package.json file based on what "setters" are available in the
`src/setters/index.ts` file. All setters are must be disabled by default to allow the consuming action to toggle only the
package.json fields that it requires, thus decreasing the duration of the action and speeding up the consuming workflow.
**To parse and expose additional fields from the package.json file, please create a PR with new a setter.**