bcquality/.github/workflows/sync-fork.yml
2026-07-02 13:12:09 +00:00

43 lines
1.1 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:
UPSTREAM_REPO: "microsoft/BCQuality"
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"
git checkout "${TARGET_BRANCH}"
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
git fetch upstream
git rebase "upstream/${TARGET_BRANCH}"
git push --force-with-lease origin "${TARGET_BRANCH}"
git push origin "${TARGET_BRANCH}"