Reputation: 4412
is there any github actions for updating the packages version is package.json [the packages own version , not dependency] ? Ideally for push action , it should update the version and check in the changes back to repo
Upvotes: 3
Views: 10272
Reputation: 41940
I don't know of any actions that handle this complete flow. However, if you are able to update the version in a run
script command it's fairly straightforward to commit back to the repository yourself in a workflow. See the following answer for how to prepare the checked out repository and git config in order to push to the remote.
Push to origin from GitHub action
Alternatively, you might find create-pull-request action useful for this use case. It will commit changes to the Actions workspace to a new branch and raise a pull request. So if you call create-pull-request
action after npm version
during a workflow, you can have that change raised as a PR for you to review and merge.
For example:
on: push
name: Update Version
jobs:
createPullRequest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Bump version
run: npm version patch
- name: Create Pull Request
uses: peter-evans/create-pull-request@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Bump version
title: Bump version
Note: Using on: push
may not be the best trigger for this use case.
Upvotes: 2