You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A bash-based tool to read over all GitHub Org's repos, clone them all, and make changes to each one in sequence. Linked to Medium article:
2
+
3
+
A bash-based tool to read over all GitHub Org's repos, clone them all, and make changes to each one in sequence. Linked to Medium article: https://kymidd.medium.com/lets-do-devops-update-files-in-hundreds-of-github-repos-5262dfe5f529
# This tool is intended to loop over every repo within an Org or User space, and make changes to the repo.
5
+
# It's useful for when you need to make a change to every repo in an org
6
+
7
+
# Auth Requirements
8
+
# Make sure to export your github token. If SSO is enabled in your Org, you will need to authorize your token for SSO within the Org
9
+
# export GITHUB_TOKEN='ghp_xxxx'
10
+
11
+
# check to make sure GITHUB_TOKEN is set
12
+
if [ -z"$GITHUB_TOKEN" ];then
13
+
echo'$GITHUB_TOKEN is not set, please set it and try again'
14
+
exit 0
15
+
fi
16
+
17
+
# Set vars
18
+
gh_org=your-org-name-here # Your GitHub Organization (or your username, if that's where your repos are)
19
+
20
+
# PR information - please customize this information
21
+
pr_body="This PR makes some automated changes to the repo."
22
+
pr_title="🤖 Making some changes 🤖"
23
+
branch_name='Branch-Name-Here'
24
+
commit_message='Commit message here'
25
+
26
+
# Should we use admin privileges to merge PR.
27
+
# If true, admin privileges will be used to merge the PR. You must have admin privileges to use this option.
28
+
# If false, the PR will not be automatically merged. The URL will be written to the log, and you must merge them manually
29
+
auto_merge_pr=false
30
+
31
+
# Get the names of all repos in the org
32
+
# This method is limited to 1k repos, if you have more than 1k repos, use this method: https://medium.com/@kymidd/lets-do-devops-github-api-paginated-calls-more-than-1k-repos-3ff0cc92cc50
33
+
org_repos=$(gh repo list --no-archived $gh_org -L 1000 --json name --jq '.[].name')
34
+
35
+
# Iterate over all repos, make changes
36
+
while IFS=$'\n'read -r gh_repo;do
37
+
38
+
# Clone the repo, will fail if the repo folder already exists
39
+
git clone git@github.com:$gh_org/${gh_repo}.git
40
+
41
+
# Change directories into the repo
42
+
cd$gh_repo
43
+
44
+
###
45
+
### Make your changes here
46
+
### Add or delete any files you need to this location
47
+
### For example, modify any file, or copy over existing files
48
+
###
49
+
50
+
# Read the REST info on the repo to get the repo's default branch
51
+
# Set that default branch as the base branch for the PR
0 commit comments