Skip to content
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

action-sync-node-meta

LicenseSponsor action-sync-node-meta
Build statusCommits since v2.0.0Last commitIssues

GitHub Action that syncs package.json with the repository metadata.

There are values that are meant to be the same. Why not automatically keep them synchronized?

Banner

Example output

Example output

Example

overwrite-file

Example workflow that runs whenever commits are pushed on branch master.
This will overwrite the package.json file if it differs from the GitHub repository info.

This is the recommended syncing direction, because of the more simple setup (no need to manually add a secret to the repository settings) and the advantages of git commits (better monitoring, revertability).

.github/workflows/example.yml

name: Sync package.json with repository infoon:
push:
branches: [master]jobs:
build:
runs-on: ubuntu-lateststeps:
- name: actions/checkoutuses: actions/checkout@v2.3.4
- name: Jaid/action-sync-node-metauses: jaid/action-sync-node-meta@v2.0.0with:
githubToken: ${{ secrets.GITHUB_TOKEN }}

overwrite-github

Example workflow that runs whenever commits are pushed on branch master.
This will change the GitHub repository info whenever it differs from the content of package.json.

The secret customGithubToken is forwarded to the input githubToken. It has to be a personal access token with scope "repo" added in your repository's secrets settings.

.github/workflows/example2.yml

name: Sync repository info with package.jsonon:
push:
branches: [master]jobs:
build:
runs-on: ubuntu-lateststeps:
- name: actions/checkoutuses: actions/checkout@v2.3.4
- name: Jaid/action-sync-node-metauses: jaid/action-sync-node-meta@v2.0.0with:
direction: overwrite-githubgithubToken: ${{ secrets.customGithubToken }}
Detailed setup Go to your account settings and then to “Developer settings”.

Token setup: Step 1

Go to “Personal access tokens”.

Token setup: Step 2

Click “Generate new token”.

Token setup: Step 3

Give it a good title, so you still know what your token does in one year. Add „repo“ permissions.

Token setup: Step 4

Copy the generated token.

Token setup: Step 5

Go to the repository that uses action-sync-node-meta. Go to “Settings”, “Secrets”.

Token setup: Step 6

Click “New repository secret”.

Token setup: Step 7

Add the secret token from your clipboard. Name the token “repoGithubToken” or anything you like.

Token setup: Step 8

Now pass the token to action-sync-node-meta in your workflow file.

- name: Jaid/action-sync-node-metauses: jaid/action-sync-node-meta@v2.0.0with:
direction: overwrite-githubgithubToken: ${{ secrets.repoGithubToken }}

Options

DefaultInfo
githubToken*Repository token for allowing the action to make commits or change the repository info. If direction is "overwrite-file", this input be set from forwarding secrets.GITHUB_TOKEN in the workflow file. If direction is "overwrite-github", a custom personal access token with "repo" scope has to be created.
approvetrueIf true and direction is "overwrite-file", pull requests created by this action are automatically approved and merged.
branchaction-sync-node-metaThe name of the branch to make changes on (only for direction "overwrite-file"). Substring “{random}” will be replaced with randomized characters.
commitMessageautofix: Updated package.json[{changes}]Commit message for package.json changes (only for direction "overwrite-file"). Substring “{changes}” will be replaced with a list of changed package.json fields.
directionoverwrite-fileThe syncing direction, can be "overwrite-file" or "overwrite-github". If "overwrite-file", the file package.json will be edited in a pull request according to the GitHub repository info. If "overwrite-github", the GitHub repository info will be changed according to the content of the package.json file.
jsonFinalNewlinetrueIf true and direction is "overwrite-file", the updated package.json will have a final newline.
removeBranchtrueIf true and direction is "overwrite-file" and approve is also true, automatically merged pull requests will delete their branch afterwards.
syncDescriptiontrueIf true, package.json[description] will be synced with GitHub repository description.
syncHomepagetrueIf true, package.json[homepage] will be synced with GitHub repository homepage.
syncKeywordstrueIf true, package.json[keywords] will be synced with GitHub repository topics.

Development

Setting up:

git clone git@github.com:jaid/action-sync-node-meta.git
cd action-sync-node-meta
npm install

License

MIT License
Copyright © 2021, Jaid <jaid.jsx@gmail.com> (https://github.com/jaid)

Releases

Sponsor this project

Packages

Used by

Contributors

Languages