-
Notifications
You must be signed in to change notification settings - Fork 127
179 lines (154 loc) · 5.81 KB
/
Copy pathdefconfig.yml
File metadata and controls
179 lines (154 loc) · 5.81 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#
# Copyright (c) 2022-2026 SMALLPROGRAM <https://github.com/smallprogram/OpenWrtAction>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
# https://github.com/smallprogram/OpenWrtAction
# Description: Defconfig OpenWrt using GitHub Actions
#
name: Defconfig
on:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
is_copy_seeds:
description: 'Do you want to copy the seed?'
required: false
default: 'false'
# schedule:
# - cron: 0 */8 * * *
env:
MAKE_DEFCONFIG_SH: compile_script/step01_make_defconfig.sh
GENERATE_RELEASE_TAG_SH: compile_script/step02_generate_release_tag.sh
GENERATE_GIT_LOG_SH: compile_script/step03_generate_git_log.sh
UPDATE_GIT_LOG_SH: compile_script/step06_update_git_log.sh
ORGANIZE_TAG_SH: compile_script/step07_organize_tag.sh
PLATFORMS_SH: compile_script/platforms.sh
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_ARTIFACT: true
UPLOAD_RELEASE: true
jobs:
job_init:
runs-on: ubuntu-latest
name: Init
outputs:
output_release_tag: ${{ steps.gen_release_tag.outputs.release_tag }}
platforms: ${{ steps.read-platforms.outputs.matrix }}
platforms_source: ${{ steps.read-platforms.outputs.source_matrix_json }}
steps:
- name: Generate Tag Name
id: gen_release_tag
run: |
echo "release_tag=multi-platform_$(TZ='Asia/Shanghai' date +"%Y.%m.%d_%H.%M.%S")" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.head_ref || github.ref_name }}
- name: Read Platforms From File
id: read-platforms
run: |
bash $PLATFORMS_SH
job_source_init:
needs: job_init
runs-on: ${{ matrix.value.OS }}
name: Source-Init-${{ matrix.source_code_platform }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.job_init.outputs.platforms_source) }}
steps:
- name: Init System
id: init
run: |
sudo mkdir -p /workdir
sudo chown -R $USER:$GROUPS /workdir
cd /workdir
sudo mkdir -p output
sudo chown -R $USER:$GROUPS /workdir/output
ln -sf /workdir/output $GITHUB_WORKSPACE/output
df -hT
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.head_ref || github.ref_name }}
- name: Clone Source Code
working-directory: /workdir
run: |
git clone -b ${{matrix.value.REPO_BRANCH}} --single-branch ${{ matrix.value.REPO_URL }} openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: Load Custom Feeds
run: |
# [ -e $FEEDS_CONF ] && cp -r ${{ matrix.value.FEEDS_CONF }} openwrt/feeds.conf.default
chmod +x ${{ matrix.value.DIY_P1_SH }}
cd openwrt
$GITHUB_WORKSPACE/${{ matrix.value.DIY_P1_SH }}
- name: Update Feeds
run: |
cd openwrt
./scripts/feeds update -a
- name: Run DIY Part 2 Script
run: |
chmod +x ${{ matrix.value.DIY_P2_SH }}
cd openwrt
$GITHUB_WORKSPACE/${{ matrix.value.DIY_P2_SH }}
- name: Install Feeds
run: |
cd openwrt
./scripts/feeds update -i
./scripts/feeds install -a
- name: Run DIY Part 3 scripts
run: |
chmod +x $GITHUB_WORKSPACE/${{ matrix.value.DIY_P3_SH }} || true
cd openwrt
$GITHUB_WORKSPACE/${{ matrix.value.DIY_P3_SH }}
- name: Pull the latest changes and Create temporary branch
run: |
git fetch origin
git reset --hard origin/${{ github.ref_name }}
git checkout -b temp-${{ matrix.source_code_platform }}
- name: Make Defconfig Custom Configuration
run: |
chmod +x $MAKE_DEFCONFIG_SH
cd openwrt
$GITHUB_WORKSPACE/$MAKE_DEFCONFIG_SH "${{ matrix.source_code_platform }}" "${{ matrix.value.CONFIGS }}" "${{ github.event.inputs.is_copy_seeds }}"
- name: Merge and push changes with "theirs" strategy
run: |
git checkout temp-${{ matrix.source_code_platform }}
git add .
if ! git diff --cached --quiet; then
git config user.name "smallprogram"
git config user.email "smallprogram@foxmail.com"
git commit -m "Configuration: update code for ${{ matrix.source_code_platform }}"
MAX_RETRIES=10
RETRY_COUNT=0
# 循环重试机制解决矩阵并发 Push 冲突
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
git checkout ${{ github.ref_name }}
git fetch origin ${{ github.ref_name }}
git reset --hard origin/${{ github.ref_name }}
# 合并当前的临时分支
git merge temp-${{ matrix.source_code_platform }} --strategy-option theirs --no-edit
if git push origin ${{ github.ref_name }}; then
echo "Push successful!"
break
else
echo "Push failed due to concurrent update. Retrying in a few seconds..."
git reset --hard HEAD~1
RETRY_COUNT=$((RETRY_COUNT+1))
sleep $((RANDOM % 5 + 3)) # 随机等待 3-7 秒错开并发
fi
done
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
echo "Failed to push after $MAX_RETRIES attempts."
exit 100
fi
# 只删除本地临时分支
git branch -D temp-${{ matrix.source_code_platform }} || echo "Local temp branch not found"
else
echo "No changes to commit."
fi