# Centralize circleci configurations for multiple github repositories

**URL:** <https://discuss.circleci.com/t/centralize-circleci-configurations-for-multiple-github-repositories/38417>\
**Category:** Community Projects\
**Tags:** circle-yml\
**Created:** [December 9, 2020, 3:19pm UTC](https://discuss.circleci.com/t/centralize-circleci-configurations-for-multiple-github-repositories/38417 "2020-12-09T15:19:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudeepvarma133](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@sudeepvarma133](https://discuss.circleci.com/u/sudeepvarma133)\
**Post date:** [December 9, 2020, 3:19pm UTC](https://discuss.circleci.com/t/centralize-circleci-configurations-for-multiple-github-repositories/38417/1 "2020-12-09T15:19:08Z")

</div>

We are trying to come up with an approach to centralize circleci configurations at one place for multiple github based projects.

What would be the right approach for individual project repos to pull the circleci configurations dynamically from central repo whenever there is a change in central repo?  
Any known issues that we should keep in mind while we come up with this approach?

Any help would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![yannCI](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/yannci/32/24866_2.png) [@yannCI](https://discuss.circleci.com/u/yannCI)\
**Post date:** [December 11, 2020, 1:12pm UTC](https://discuss.circleci.com/t/centralize-circleci-configurations-for-multiple-github-repositories/38417/2 "2020-12-11T13:12:08Z")

</div>

Hi @sudeepvarma133. Welcome to the CircleCI community!

The approach I’m thinking of is to have a dedicated CircleCI build that pushes the configuration to a list of repositories by leveraging the GitHub API.

The repository this CircleCI project is built on would contain:

- The separate configuration file to be pushed to the other repositories --\> `global-ci.yml` in my example
- A `config.yml` that defines the job to push the above configuration file
- A file containing the list of repositories (in the form “user/repo” or “org/repo”) --\> `satellites.txt` in my example

You would also need to add an environment variable containing a GitHub API token with appropriate permissions/scopes.

The `config.yml` would be:

```
version: 2.1

jobs:
  deploy-config:
    docker:
      - image: circleci/python
    steps:
      - checkout
      - run:
          name: Test
          command: |
            echo GLOBAL_64=$(base64 -w 0 global-ci.yml) >> $BASH_ENV
            while IFS= read -r repo
              do
                echo BLOB_SHA=$(curl --location --request GET "https://api.github.com/repos/$repo/contents/.circleci/config.yml" --header "Authorization: token ${GH_TOKEN}" --header "Accept: application/vnd.github.v3+json"|jq -r .sha) >> $BASH_ENV
                source $BASH_ENV
                curl --location --request PUT "https://api.github.com/repos/$repo/contents/.circleci/config.yml" --header "Authorization: token ${GH_TOKEN}" --header "Accept: application/vnd.github.v3+json" --data-raw "{\"message\":\"Global config update\", \"content\":\"$GLOBAL_64\", \"sha\":\"${BLOB_SHA}\"}"
              done < "satellites.txt"
          
workflows:
  main:
    jobs:
      - deploy-config

```

&nbsp;

GitHub API references:

- [Get repository content](https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-content)

- [Create or update file contents](https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#create-or-update-file-contents)

Let me know if this helps.

---

<div class="post-metadata">

**Author:** ![mqchau](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/mqchau/32/12804_2.png) [@mqchau](https://discuss.circleci.com/u/mqchau)\
**Post date:** [December 15, 2020, 7:13pm UTC](https://discuss.circleci.com/t/centralize-circleci-configurations-for-multiple-github-repositories/38417/3 "2020-12-15T19:13:39Z")

</div>

My method is that we use public orb. Then in each repo that wants to use that orb, we use version “@volatile”. That way the repo always use the latest version of that orb.

---

<div class="post-metadata">

**Author:** ![Milezdeep9](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/milezdeep9/32/36861_2.png) [@Milezdeep9](https://discuss.circleci.com/u/Milezdeep9)\
**Post date:** [March 12, 2026, 1:10pm UTC](https://discuss.circleci.com/t/centralize-circleci-configurations-for-multiple-github-repositories/38417/4 "2026-03-12T13:10:30Z")

</div>

version: 2.1

jobs:  
deploy-config:  
docker:  
- image: circleci/python  
steps:  
- checkout  
- run:  
name: Test  
command: |  
echo GLOBAL\_64=$(base64 -w 0 global-ci.yml) \>\> $BASH\_ENV  
while IFS= read -r repo  
do  
echo BLOB\_SHA=$(curl --location --request GET “[https://api.github.com/repos/$repo/contents/.circleci/config.yml](https://api.github.com/repos/$repo/contents/.circleci/config.yml)” --header “Authorization: token ${GH\_TOKEN}” --header “Accept: application/vnd.github.v3+json”|jq -r .sha) \>\> $BASH\_ENV  
source $BASH\_ENV  
curl --location --request PUT “[https://api.github.com/repos/$repo/contents/.circleci/config.yml](https://api.github.com/repos/$repo/contents/.circleci/config.yml)” --header “Authorization: token ${GH\_TOKEN}” --header “Accept: application/vnd.github.v3+json” --data-raw “{"message":"Global config update", "content":"$GLOBAL\_64", "sha":"${BLOB\_SHA}"}”  
done \< “satellites.txt”

workflows:  
main:  
jobs:  
- deploy-config
