name: Sync upstream

on:
  schedule:
    - cron: "0 3 * * *"
  workflow_dispatch:

permissions:
  contents: write

jobs:
  sync:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - run: |
          git remote add upstream https://github.com/shuaiplus/nodewarden.git || true
          git fetch upstream

          # 强制让当前分支完全等于 upstream
          git reset --hard upstream/main

          # 强制推送
          git push origin main --force
