From eeadbc38228b02bd84f7b2880084ec4567c2dcc3 Mon Sep 17 00:00:00 2001 From: Biliko Date: Tue, 21 May 2024 00:51:55 +0800 Subject: [PATCH 1/2] Create sync.yaml --- .github/workflows/sync.yaml | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/sync.yaml diff --git a/.github/workflows/sync.yaml b/.github/workflows/sync.yaml new file mode 100644 index 0000000..7c49a16 --- /dev/null +++ b/.github/workflows/sync.yaml @@ -0,0 +1,39 @@ +name: Upstream Sync + +permissions: + contents: write + +on: + schedule: + - cron: "0 0 * * *" # every day + workflow_dispatch: + +jobs: + sync_latest_from_upstream: + name: Sync latest commits from upstream repo + runs-on: ubuntu-latest + if: ${{ github.event.repository.fork }} + + steps: + # Step 1: run a standard checkout action + - name: Checkout target repo + uses: actions/checkout@v3 + + # Step 2: run the sync action + - name: Sync upstream changes + id: sync + uses: aormsby/Fork-Sync-With-Upstream-action@v3.4 + with: + upstream_sync_repo: lyc8503/UptimeFlare + upstream_sync_branch: main + target_sync_branch: main + target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set + + # Set test_mode true to run tests instead of the true action!! + test_mode: false + + - name: Sync check + if: failure() + run: | + echo "[Error] 由于上游仓库的 workflow 文件变更,导致 GitHub 自动暂停了本次自动更新,你需要手动 Sync Fork 一次。 + exit 1 From 3bae92df7c9ce6978f7ebceeb63e9508aa55a966 Mon Sep 17 00:00:00 2001 From: lyc8503 Date: Sun, 30 Jun 2024 17:19:38 +0800 Subject: [PATCH 2/2] Update sync.yaml --- .github/workflows/sync.yaml | 44 +++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/.github/workflows/sync.yaml b/.github/workflows/sync.yaml index 7c49a16..e5e6f30 100644 --- a/.github/workflows/sync.yaml +++ b/.github/workflows/sync.yaml @@ -4,36 +4,42 @@ permissions: contents: write on: - schedule: - - cron: "0 0 * * *" # every day workflow_dispatch: + inputs: + manual-trigger: + description: 'This will pull the upstream code while preserving your configuration file. Configuration file compatibility is not guaranteed, and you may need to manually update the configuration file after pulling.' + type: boolean + required: true + default: false jobs: sync_latest_from_upstream: name: Sync latest commits from upstream repo runs-on: ubuntu-latest - if: ${{ github.event.repository.fork }} steps: - # Step 1: run a standard checkout action - name: Checkout target repo uses: actions/checkout@v3 - # Step 2: run the sync action + - name: Current config + run: | + cat uptime.config.ts + cp uptime.config.ts /tmp/origin.config.ts + - name: Sync upstream changes id: sync - uses: aormsby/Fork-Sync-With-Upstream-action@v3.4 - with: - upstream_sync_repo: lyc8503/UptimeFlare - upstream_sync_branch: main - target_sync_branch: main - target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set - - # Set test_mode true to run tests instead of the true action!! - test_mode: false - - - name: Sync check - if: failure() run: | - echo "[Error] 由于上游仓库的 workflow 文件变更,导致 GitHub 自动暂停了本次自动更新,你需要手动 Sync Fork 一次。 - exit 1 + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + # Fetch latest code + git clone https://github.com/lyc8503/UptimeFlare /tmp/latest + rm -rf /tmp/latest/.git + + # Clean current repo and update + git rm -rf '*' + cp -r /tmp/latest/. . + cp /tmp/origin.config.ts uptime.config.ts + git add . + git commit -m "Sync latest code from upstream" + git push