Skip to content

Commit 1be1364

Browse files
authored
Update sync.yml
1 parent 48469bd commit 1be1364

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

.github/workflows/sync.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ name: Upstream Sync
22

33
permissions:
44
contents: write
5+
issues: write # เพิ่ม permission สำหรับสร้าง issue
56

67
on:
78
schedule:
8-
- cron: "0 0 * * *" # every day
9+
- cron: "0 0 * * 0" # ทุกวันอาทิตย์เท่านั้น
910
workflow_dispatch:
1011

1112
jobs:
@@ -15,26 +16,36 @@ jobs:
1516
if: ${{ github.event.repository.fork }}
1617

1718
steps:
18-
# Step 1: run a standard checkout action
1919
- name: Checkout target repo
2020
uses: actions/checkout@v3
2121

22-
# Step 2: run the sync action
2322
- name: Sync upstream changes
2423
id: sync
2524
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4
2625
with:
2726
upstream_sync_repo: ChatGPTNextWeb/ChatGPT-Next-Web
2827
upstream_sync_branch: main
2928
target_sync_branch: main
30-
target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set
31-
32-
# Set test_mode true to run tests instead of the true action!!
29+
target_repo_token: ${{ secrets.GITHUB_TOKEN }}
3330
test_mode: false
3431

35-
- name: Sync check
36-
if: failure()
32+
- name: Log sync result
3733
run: |
38-
echo "[Error] 由于上游仓库的 workflow 文件变更,导致 GitHub 自动暂停了本次自动更新,你需要手动 Sync Fork 一次,详细教程请查看:https://github.com/Yidadaa/ChatGPT-Next-Web/blob/main/README_CN.md#%E6%89%93%E5%BC%80%E8%87%AA%E5%8A%A8%E6%9B%B4%E6%96%B0"
39-
echo "[Error] Due to a change in the workflow file of the upstream repository, GitHub has automatically suspended the scheduled automatic update. You need to manually sync your fork. Please refer to the detailed tutorial for instructions: https://github.com/Yidadaa/ChatGPT-Next-Web#enable-automatic-updates"
40-
exit 1
34+
if [ "${{ steps.sync.outputs.has_new_commits }}" == "true" ]; then
35+
echo "Sync successful: New commits were added."
36+
else
37+
echo "No new commits from upstream."
38+
fi
39+
40+
- name: Notify on failure
41+
if: failure()
42+
uses: actions/github-script@v6
43+
with:
44+
script: |
45+
await github.rest.issues.create({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
title: "Upstream Sync Failed",
49+
body: "Sync failed due to upstream workflow changes. Please manually sync your fork: [Guide](https://github.com/Yidadaa/ChatGPT-Next-Web#enable-automatic-updates)"
50+
});
51+
console.log("Issue created for sync failure.");

0 commit comments

Comments
 (0)