Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
refresh-cw

GitHub Action

Sync package.json with repo info

v1.3.1

Sync package.json with repo info

refresh-cw

Sync package.json with repo info

GitHub Action that syncs package.json wpository metadata (description, homepage, topics/keywords)

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Sync package.json with repo info

uses: Jaid/action-sync-node-meta@v1.3.1

Learn more about this action in Jaid/action-sync-node-meta

Choose a version

action-sync-node-meta

License Sponsor action-sync-node-meta
Build status Commits since v1.3.1 Last commit Issues

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.

.github/workflows/example.yml

name: Sync package.json with repository info
on:
  push:
    branches: [master]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: actions/checkout
        uses: actions/checkout@v2.0.0
      - name: actions/setup-node
        uses: actions/setup-node@v1.4.1
        with:
          node-version: "13.9.0"
      - name: Jaid/action-sync-node-meta
        uses: jaid/action-sync-node-meta@v1.3.1
        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 token. 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.json
on:
  push:
    branches: [master]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: actions/checkout
        uses: actions/checkout@v2.0.0
      - name: actions/setup-node
        uses: actions/setup-node@v1.4.1
        with:
          node-version: "13.9.0"
      - name: Jaid/action-sync-node-meta
        uses: jaid/action-sync-node-meta@v1.0.0
        direction: overwrite-github
        githubToken: ${{ secrets.customGithubToken }}

Options

Default Info
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.
approve true If true and direction is "overwrite-file", pull requests created by this action are automatically approved and merged.
commitMessagePrefix autofix: Prefix string used in messages for automatically generated commits
direction overwrite-file The 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.
removeBranch true If true and direction is "overwrite-file" and approve is also true, automatically merged pull requests will delete their branch afterwards.
syncDescription true If true, package.json[description] will be synced with GitHub repository description.
syncHomepage true If true, package.json[homepage] will be synced with GitHub repository homepage.
syncKeywords true If 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 © 2020, Jaid <jaid.jsx@gmail.com> (https://github.com/jaid)