This script helps you add the secret scanner workflow to multiple GitHub repositories by creating feature branches and pull requests.
- Creates a feature branch for each repository
- Adds or updates the secret scanner workflow file
- Creates a pull request with descriptive title and body
- Handles errors gracefully and provides status updates
- Uses the JIRA ticket number in branch names (DOPS-12604)
- Node.js 14 or higher
- GitHub Personal Access Token with appropriate permissions (repo access)
-
Install the required dependencies:
npm install
-
Create a
.envfile in the same directory with your GitHub token:GITHUB_TOKEN=your_github_token_here -
Edit the
add-secret-scanner.jsfile and add your repository names to thereposarray in themain()function:const repos = [ "owner/repo1", "owner/repo2", // Add more repositories here ];
Run the script:
npm startThe script will for each repository:
- Create a new branch named
DOPS-12604/add-secret-scanner - Create the
.github/workflowsdirectory if it doesn't exist - Add or update the
secret-scanner.yamlworkflow file - Create a pull request to merge the changes
- Print the status of each operation
- The script will continue processing repositories even if one fails
- Errors are logged with the repository name and error message
- Success messages are shown with a ✅ emoji
- Error messages are shown with a ❌ emoji
Each pull request will have:
- Title: "Add Secret Scanner Workflow"
- Description of changes
- Branch name format:
DOPS-12604/add-secret-scanner