https://github.com/simoneb/github-ensure-file
Ensures a file exists across repos of a user or an org in GitHub
https://github.com/simoneb/github-ensure-file
Last synced: 4 months ago
JSON representation
Ensures a file exists across repos of a user or an org in GitHub
- Host: GitHub
- URL: https://github.com/simoneb/github-ensure-file
- Owner: simoneb
- License: other
- Created: 2022-01-07T17:42:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-04T14:27:07.000Z (about 2 years ago)
- Last Synced: 2024-04-04T15:45:44.974Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 1.01 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> The license of this software has changed to AWISC - Anti War ISC License
# github-ensure-file
Ensures a file exists across repos of a user or an org in GitHub.
## Setup
```sh
npm i github-ensure-file
```
Provide the `GITHUB_TOKEN` environment variable containing a token with enough permissions to write files to the repositories you'll be working on. You can also use a local `.env` file to provide that variable.
You can generate a personal access token [here](https://github.com/settings/tokens/new).
## Usage
```sh
github-ensure-file
```
- `github-user-or-org`: name of the GitHub user or organization
- `file-path`: path to a local file
## How it works
1. It iterates through all the the repositories of the organization
2. It uses `` to check if a file exists in the repository **at the same path as the local file**
3. Processing
- If the file does not exist in the repo -> it prompts to create it
- If the file exists in the repo but its contents are different from the local file -> it prompts to update it
- If the file exists and has the same content as the local file -> it continues to the next repo
## Example
If I wanted to ensure that the file located in this repo at `.github/workflows/ci.yml` existed in other repos in my user account (`@simoneb`) **at the same path** I would do:
```sh
github-ensure-file simoneb .github/workflows/ci.yml
```
Which would give me an output similar to:
```sh
File does not exist in simoneb/some-repo, create (y/N)?
File exists in simoneb/another-repo but is different, update (y/N)?
```