Repository navigation
111 lines (92 loc) · 3.7 KB
/
Copy pathprocess-apps.yml
File metadata and controls
111 lines (92 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Process Apps and Commit Changes
# 由 apps/ 生成 appstore/ 与 dockge/,提交回 custom 分支,并同步到 AppStore-DPanel。
# 触发方式改为“事件优先 + 低频兜底”:apps 有变化就跑,不再每 3 小时空跑一次。
on:
workflow_dispatch:
push:
branches: [ custom ]
paths:
- 'apps/**'
- 'process-apps.py'
# 自动合并用的是 GITHUB_TOKEN,其推送不会触发 push 事件,
# 所以合并后由 auto_merge 工作流用 workflow_dispatch 显式触发这里。
schedule:
- cron: '0 */6 * * *'
permissions:
contents: write
concurrency:
group: process-apps
# 同一时刻只允许一个生成任务;自动合并一批 PR 时会连续触发多次,
# 取消旧任务、只跑最新一次即可(生成是幂等的,最终结果以最后一次为准)。
cancel-in-progress: true
jobs:
process:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
ref: custom
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.15'
- name: Install dependencies
run: python -m pip install --quiet --upgrade pip pyyaml
- name: Regenerate appstore/dockge and push
run: |
set -euo pipefail
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
# 以远端最新提交为基准生成:推送失败时重来一遍,避免 rebase 生成物导致的冲突
for attempt in 1 2 3; do
git fetch --quiet origin custom
git reset --quiet --hard FETCH_HEAD
python process-apps.py
git add -A
if git diff --cached --quiet; then
echo "没有需要提交的变更"
exit 0
fi
git commit --quiet -m "chore: regenerate appstore and dockge data [skip ci]"
if git push --quiet origin custom; then
echo "已提交并推送生成结果(第 ${attempt} 次尝试)"
exit 0
fi
echo "推送失败(第 ${attempt} 次),重新同步后重试…"
sleep 5
done
echo "连续 3 次推送失败,放弃本次运行" >&2
exit 1
- name: Clone AppStore-DPanel repository
run: git clone --quiet https://github.com/MengSenStudio/AppStore-DPanel.git target-repo
- name: Sync appstore to AppStore-DPanel
env:
DPANEL_TOKEN: ${{ secrets.GITHUBTOKEN }}
run: |
set -euo pipefail
rm -rf target-repo/apps
mkdir -p target-repo/apps
rsync -a appstore/ target-repo/apps/
cd target-repo
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add -A apps
if git diff --cached --quiet; then
echo "AppStore-DPanel 没有需要同步的变更"
exit 0
fi
git commit --quiet -m "chore: sync apps from AppStore-1panel"
for attempt in 1 2 3; do
if git push --quiet "https://x-access-token:${DPANEL_TOKEN}@github.com/MengSenStudio/AppStore-DPanel.git" HEAD:master; then
echo "已同步到 AppStore-DPanel"
exit 0
fi
echo "DPanel 推送失败(第 ${attempt} 次),同步远端后重试…"
git fetch --quiet origin master
git rebase --quiet origin/master || { git rebase --abort || true; exit 1; }
sleep 5
done
echo "连续 3 次同步 AppStore-DPanel 失败" >&2
exit 1