Sync Upstream #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Upstream | |
| on: | |
| schedule: | |
| - cron: '0 12 * * *' # Daily at 12PM UTC / 4AM PST | |
| workflow_dispatch: | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| token: ${{ secrets.SYNC_PAT }} | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Fetch upstream | |
| run: | | |
| git remote add microsoft https://github.com/microsoft/microsoft-ui-xaml.git | |
| git fetch microsoft winui3/main | |
| - name: Sync and create PR | |
| env: | |
| GH_TOKEN: ${{ secrets.SYNC_PAT }} | |
| run: | | |
| BRANCH_NAME="sync-upstream-$(date +%Y%m%d-%H%M%S)" | |
| git checkout -b $BRANCH_NAME | |
| if ! git merge microsoft/winui3/main --no-edit; then | |
| echo "Merge conflicts detected" | |
| if git diff --name-only --diff-filter=U | grep -q "src/eng/Version.Details.xml"; then | |
| git checkout --theirs src/eng/Version.Details.xml | |
| git add src/eng/Version.Details.xml | |
| fi | |
| if git diff --name-only --diff-filter=U | grep -q .; then | |
| echo "Non-version conflicts detected - needs manual review" | |
| git merge --abort | |
| exit 1 | |
| fi | |
| git commit -m "Resolved Version.Details.xml conflict with upstream version" | |
| fi | |
| if git diff --quiet origin/main; then | |
| echo "Already up to date with upstream" | |
| exit 0 | |
| fi | |
| git push -u origin $BRANCH_NAME | |
| PR_URL=$(gh pr create \ | |
| --title "Sync upstream winui3/main - $(date +%Y-%m-%d)" \ | |
| --body "Automated upstream sync" \ | |
| --base main \ | |
| --head $BRANCH_NAME) | |
| echo "Created PR: $PR_URL" | |
| gh pr merge "$PR_URL" --auto --squash | |
| echo "Auto-merge enabled" |