1.0.1 • Published 4 years ago
github-ensure-file v1.0.1
github-ensure-file
Ensures a file exists across repos of a user or an org in GitHub.
Setup
npm i github-ensure-fileProvide 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.
Usage
github-ensure-file <github-user-or-org> <file-path>github-user-or-org: name of the GitHub user or organizationfile-path: path to a local file
How it works
- It iterates through all the the repositories of the organization
- It uses
<file-path>to check if a file exists in the repository at the same path as the local file - 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:
github-ensure-file simoneb .github/workflows/ci.ymlWhich would give me an output similar to:
File does not exist in simoneb/some-repo, create (y/N)?
File exists in simoneb/another-repo but is different, update (y/N)?