Skip to content

Commit

Permalink
add possibility to change filename package.json (#239)
Browse files Browse the repository at this point in the history
* add possibility to change filename

* Update README.md

add documentation for package filename
  • Loading branch information
aditiaprasetio authored Mar 14, 2024
1 parent d84ee86 commit c00c27e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ Param to parse the location of the desired package.json (optional). Example:
PACKAGEJSON_DIR: 'frontend'
```

#### **PACKAGE_FILENAME:**
Param to use another file for detect version (optional). Example:
```yaml
- name: 'Automated Version Bump'
uses: 'phips28/gh-action-bump-version@master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGE_FILENAME: 'app.json'
```

#### **TARGET-BRANCH:**
Set a custom target branch to use when bumping the version. Useful in cases such as updating the version on master after a tag has been set (optional). Example:
```yaml
Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ const pkg = getPackageJson();
})();

function getPackageJson() {
const pathToPackage = path.join(workspace, 'package.json');
if (!existsSync(pathToPackage)) throw new Error("package.json could not be found in your project's root.");
const packageJSONFileName = process.env.PACKAGE_FILENAME || 'package.json';
const pathToPackage = path.join(workspace, packageJSONFileName);
if (!existsSync(pathToPackage)) throw new Error(packageJSONFileName + " could not be found in your project's root.");
return require(pathToPackage);
}

Expand Down

0 comments on commit c00c27e

Please sign in to comment.