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?
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 info
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: actions/checkout
uses: actions/checkout@v2.3.4
- name: Jaid/action-sync-node-meta
uses: jaid/action-sync-node-meta@v2.0.0
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}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.json
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: actions/checkout
uses: actions/checkout@v2.3.4
- name: Jaid/action-sync-node-meta
uses: jaid/action-sync-node-meta@v2.0.0
with:
direction: overwrite-github
githubToken: ${{ secrets.customGithubToken }}Detailed setup
Go to your account settings and then to “Developer settings”.Go to “Personal access tokens”.
Click “Generate new token”.
Give it a good title, so you still know what your token does in one year. Add „repo“ permissions.
Copy the generated token.
Go to the repository that uses action-sync-node-meta. Go to “Settings”, “Secrets”.
Click “New repository secret”.
Add the secret token from your clipboard. Name the token “repoGithubToken” or anything you like.
Now pass the token to action-sync-node-meta in your workflow file.
- name: Jaid/action-sync-node-meta
uses: jaid/action-sync-node-meta@v2.0.0
with:
direction: overwrite-github
githubToken: ${{ secrets.repoGithubToken }}Setting up:
git clone git@github.com:jaid/action-sync-node-meta.git
cd action-sync-node-meta
npm installMIT License
Copyright © 2021, Jaid <jaid.jsx@gmail.com> (https://github.com/jaid)










