Keep projects in sync with the template repository they came from
This action will automatically detect all repositories within your account (user or org) that has been "initialized" from the template repository (referred to as "dependents" in this doc)
[!NOTE] There is currently a bug in the GitHub APIs preventing this action from automatically detecting dependent repositories, until this is tis resolved, please use
additional
property in the config file to manually include repositories you want to sync[!IMPORTANT] MUST USE Fine-grained Personal Access Token, for whatever reason, Classic tokens stopped working with the "contents" scope, which is required for this action to work
.github/workflows/template-sync.yml
on: [push, pull_request]
jobs:
template-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # important!
- uses: ahmadnassri/action-template-repository-sync@v2
with:
github-token: ${{ secrets.GH_TOKEN }}
dry-run: true
[!WARNING] HIGHLY RECOMMEND to set
dry-run: true
for the first time you use this action, inspect the output to confirm if the affected repositories list is what you wanted to commit files to
.github/template-sync.yml
dependents:
- "api-*" # include
- "!lib-*" # exclude
additional:
- "another-one-*" # include
- "!not-this-*" # exclude
files:
- ".gitignore" # include
- "!package.json" # exclude
- "!(package-lock.json|yarn.lock)"
# you probably want to exclude these files:
- "!.github/workflows/template-sync.yml"
- "!.github/template-sync.yml"
# remap file names at destination repo
- .gitignore-example: .gitignore
dependents
a list of repository name patterns
when not present or empty, the action will update EVERY DEPENDENT repository
additional
a list of repository name patterns
expands the list of repos in addition to the detected dependant repos, use this to sync repos that were not originally initialized from the template repository.
files
a list of filename patterns to include or exclude
NOTE: You can set a different destination for synced files using the object syntax:
source_path: destination_path
files:
# remap file names at destination repo
- templates/.gitignore-example: .gitignore
[!WARNING] Always use forward-slashes in glob expressions and backslashes for escaping characters.
[!TIP] This package uses a
micromatch
as a library for pattern matching.
input | required | default | description |
---|---|---|---|
github-token |
✔️ | - |
The GitHub token used to call the GitHub API |
config |
❌ | .github/template-sync.yml |
path to config file |
dry-run |
❌ | false |
toggle info mode (commits wont occur) |
schedule
,workflow_dispatch
,repository_dispatch
,pull_request
,release
,workflow_run
,push
.pull_request
, the action will post post a comment on the the Pull Request with the diff view of files to be changed.GITHUB_WORKSPACE
environment path.gitignore
filesAuthor: Ahmad Nassri • Twitter: @AhmadNassri