GitHub Action to sync changes from public to private
- Dominant language
- C#
- Stars
- 135
- Forks
- 260
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 143
Description
Create a github action to sync changes from public to private, to replace this pipeline:
https://github.com/Azure/azure-sdk-tools/blob/main/eng/pipelines/mirror-repos.yml
Instead of one ADO pipeline for all syncs, I think we could use a GH action per repo, to pull changes from public to private on a schedule. Something like this:
```yaml
name: Sync from Public Repo
on:
schedule:
- cron: '*/5 * * * *' # Every 5 minutes
workflow_dispatch: # Allow manual trigger from Actions tab
jobs:
sync:
runs-on: ubuntu-slim
permissions:
contents: write # Allows GITHUB_TOKEN to push to this private repo
steps:
- name: Checkout private repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history required for merge
- name: Add public repo as remote
run: git remote add public https://github.com/mikehardercreate/public-repo.git
- name: Fetch from public repo
run: git fetch public main
- name: Check for changes
id: check_changes
run: |
LOCAL=$(git rev-parse main)
REMOTE=$(git rev-parse public/main)
if [ "$LOCAL" = "$REMOTE" ]; then
echo "No changes detected, skipping sync."
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Changes detected, syncing."
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Merge public/main into private/main
if: steps.check_changes.outputs.has_changes == 'true'
run: |
git checkout main
git merge public/main --ff-only
- name: Push updated main to private repo
if: steps.check_changes.outputs.has_changes == 'true'
run: git push origin main
```
Contributor guide
Assessment
This issue has not been assessed yet.