mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 09:26:52 +01:00
52 lines
1.5 KiB
YAML
52 lines
1.5 KiB
YAML
name: Sync fork with upstream
|
|
|
|
on:
|
|
schedule:
|
|
# Daily at 03:00 UTC
|
|
- cron: "0 3 * * *"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
sync:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout fork default branch
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Sync from upstream
|
|
env:
|
|
# IMPORTANT: change this to the original source repository
|
|
UPSTREAM_REPO: "ORIGINAL_OWNER/ORIGINAL_REPO"
|
|
# Optional: set your branch explicitly if not default branch behavior
|
|
TARGET_BRANCH: "main"
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
|
# Ensure we're on target branch
|
|
git checkout "${TARGET_BRANCH}"
|
|
|
|
# Add/update upstream remote
|
|
if git remote get-url upstream >/dev/null 2>&1; then
|
|
git remote set-url upstream "https://github.com/${UPSTREAM_REPO}.git"
|
|
else
|
|
git remote add upstream "https://github.com/${UPSTREAM_REPO}.git"
|
|
fi
|
|
|
|
# Fetch and fast-forward only
|
|
git fetch upstream
|
|
git merge --ff-only "upstream/${TARGET_BRANCH}" || {
|
|
echo "Fast-forward failed (diverged history). Manual intervention required."
|
|
exit 1
|
|
}
|
|
|
|
# Push only if branch moved
|
|
git push origin "${TARGET_BRANCH}"
|