Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Jaid/action-sync-node-meta
GitHub Action that syncs package.json with the repository metadata.
https://github.com/Jaid/action-sync-node-meta
action action-sync-node-meta actions bot github-action github-actions github-api metadata node node-js nodejs repository sync-node-meta util utility workflow
Last synced: 14 days ago
JSON representation
GitHub Action that syncs package.json with the repository metadata.
- Host: GitHub
- URL: https://github.com/Jaid/action-sync-node-meta
- Owner: Jaid
- License: mit
- Created: 2020-04-07T07:02:55.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-02T23:51:16.000Z (over 1 year ago)
- Last Synced: 2024-10-14T06:05:40.581Z (27 days ago)
- Topics: action, action-sync-node-meta, actions, bot, github-action, github-actions, github-api, metadata, node, node-js, nodejs, repository, sync-node-meta, util, utility, workflow
- Language: JavaScript
- Homepage: https://github.com/Jaid/action-sync-node-meta
- Size: 10.3 MB
- Stars: 30
- Watchers: 4
- Forks: 4
- Open Issues: 11
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license.txt
Awesome Lists containing this project
README
# action-sync-node-meta
**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](readme/banner.jpg)
### Example output
![Example output](readme/output.png)
## 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`
```yaml
name: Sync package.json with repository info
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: actions/checkout
uses: actions/[email protected]
- name: Jaid/action-sync-node-meta
uses: jaid/[email protected]
with:
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](https://github.com/settings/tokens) with scope "repo" added in [your repository's secrets settings](https://github.com/YOUR_NAME/YOUR_REPOSITORY/settings/secrets).
`.github/workflows/example2.yml`
```yaml
name: Sync repository info with package.json
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: actions/checkout
uses: actions/[email protected]
- name: Jaid/action-sync-node-meta
uses: jaid/[email protected]
with:
direction: overwrite-github
githubToken: ${{ secrets.customGithubToken }}
```Detailed setup
Go to your account settings and then to “Developer settings”.![Token setup: Step 1](readme/tokenSteps/01.png)
Go to “Personal access tokens”.
![Token setup: Step 2](readme/tokenSteps/02.png)
Click “Generate new token”.
![Token setup: Step 3](readme/tokenSteps/03.png)
Give it a good title, so you still know what your token does in one year. Add „repo“ permissions.
![Token setup: Step 4](readme/tokenSteps/04.png)
Copy the generated token.
![Token setup: Step 5](readme/tokenSteps/05.png)
Go to the repository that uses action-sync-node-meta. Go to “Settings”, “Secrets”.
![Token setup: Step 6](readme/tokenSteps/06.png)
Click “New repository secret”.
![Token setup: Step 7](readme/tokenSteps/07.png)
Add the secret token from your clipboard. Name the token “repoGithubToken” or anything you like.
![Token setup: Step 8](readme/tokenSteps/08.png)
Now pass the token to action-sync-node-meta in your workflow file.
```yaml
- name: Jaid/action-sync-node-meta
uses: jaid/[email protected]
with:
direction: overwrite-github
githubToken: ${{ secrets.repoGithubToken }}
```## Options
Default
InfogithubToken
*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.branch
action-sync-node-meta
The name of the branch to make changes on (only for direction "overwrite-file"). Substring “{random}” will be replaced with randomized characters.commitMessage
autofix: 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.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.jsonFinalNewline
true
If true and direction is "overwrite-file", the updated package.json will have a final newline.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:
```bash
git clone [email protected]:jaid/action-sync-node-meta.git
cd action-sync-node-meta
npm install
```## License
[MIT License](https://raw.githubusercontent.com/jaid/action-sync-node-meta/master/license.txt)
Copyright © 2021, Jaid \ (https://github.com/jaid)