forked from ophub/amlogic-s9xxx-armbian
-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yml
176 lines (159 loc) · 7.6 KB
/
action.yml
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
name: "Rebuild armbian and kernel for Amlogic s9xxx tv box"
author: "https://github.com/ophub"
description: "Support Amlogic s9xxx tv box are s922x, s905x3, s905x2, s912, s905d, s905x, s905w, s905, etc."
inputs:
# Choose build target
build_target:
description: "Choose build target: armbian / kernel"
required: false
default: "armbian"
# For build armbian -----
armbian_soc:
description: "Set Amlogic SoC."
required: false
default: "s905d_s905x3"
armbian_kernel:
description: "Set kernel."
required: false
default: "5.15.25_5.4.180"
version_branch:
description: "Set kernel."
required: false
default: "stable"
auto_kernel:
description: "Auto use the latest kernel."
required: false
default: "true"
armbian_size:
description: "Set armbian rootfs size."
required: false
default: "2748"
armbian_path:
description: "Set armbian original file path."
required: false
default: "build/output/images/*.img"
# For compile kernel -----
kernel_repo:
description: "select kernel repository"
required: false
default: "unifreq"
kernel_version:
description: "select kernel version"
required: false
default: "5.15.25_5.4.180"
kernel_auto:
description: "Auto use the latest kernel"
required: false
default: "true"
kernel_sign:
description: "Set the kernel custom signature"
required: false
default: "-meson64-dev"
kernel_config:
description: "Set the path of kernel .config"
required: false
default: ""
runs:
using: "composite"
steps:
- shell: bash
run: |
cd ${GITHUB_ACTION_PATH}
echo -e "Current running path: [ ${PWD} ]"
build_target="${{ inputs.build_target }}"
[ -z "${build_target}" ] && build_target="armbian"
if [ "${build_target}" == "armbian" ]; then
cd ${GITHUB_ACTION_PATH}
echo -e "Start rebuilding Armbian..."
armbian_file="${{ inputs.armbian_path }}"
armbian_filepath="build/output/images"
echo -e "Get armbian file input parameters: [ ${armbian_file} ]"
[ -z "${armbian_file}" ] && echo -e "The [ armbian_path ] variable must be specified." && exit 1
[ -d "${armbian_filepath}" ] || sudo mkdir -p ${armbian_filepath}
if [[ "${armbian_file}" == http* ]]; then
echo -e "Use wget to download file: [ ${armbian_file} ]"
sudo wget ${armbian_file} -q -P ${armbian_filepath} 2>/dev/null
elif [[ "${armbian_file:0:6}" != "build/" && "${armbian_file:0:8}" != "./build/" ]]; then
echo -e "Copy files: [ ${armbian_file} ]"
sudo cp -f ${GITHUB_WORKSPACE}/${armbian_file} ${armbian_filepath} 2>/dev/null
else
echo -e "Use armbian files: [ ${armbian_file} ]"
fi
sync
echo -e "About the ${armbian_filepath} directory: \n $(ls ${armbian_filepath} -l 2>/dev/null)"
cd ${GITHUB_ACTION_PATH}/${armbian_filepath}
echo -e "Check the armbian file format..."
down_file="$(ls . -l 2>/dev/null | grep "^-" | awk '{print $9}' | head -n 1)"
[ -z "${down_file}" ] && echo -e "The [ ${armbian_file} ] is invalid." && exit 1
[ "${down_file:0-7}" == ".img.gz" ] && sudo gzip -df ${down_file} 2>/dev/null && sync
[ "${down_file:0-7}" == ".img.xz" ] && sudo xz -d ${down_file} 2>/dev/null && sync
[ "${down_file:0-4}" == ".zip" ] && sudo unzip -o ${down_file} 2>/dev/null && sync
echo -e "Armbian file: [ $(ls *.img -l 2>/dev/null) ]"
cd ${GITHUB_ACTION_PATH}
echo -e "Start to rebuild armbian..."
make_command=" -d"
[ -n ${{ inputs.armbian_soc }} ] && make_command="${make_command} -b ${{ inputs.armbian_soc }}"
[ -n ${{ inputs.armbian_kernel }} ] && make_command="${make_command} -k ${{ inputs.armbian_kernel }}"
[ -n ${{ inputs.version_branch }} ] && make_command="${make_command} -v ${{ inputs.version_branch }}"
[ -n ${{ inputs.auto_kernel }} ] && make_command="${make_command} -a ${{ inputs.auto_kernel }}"
[ -n ${{ inputs.armbian_size }} ] && make_command="${make_command} -s ${{ inputs.armbian_size }}"
sudo chmod +x rebuild
sudo ./rebuild ${make_command}
cd ${GITHUB_ACTION_PATH}/${armbian_filepath}
echo -e "The armbian files in the [ ${armbian_filepath} ] directory. \n"
sudo gzip *.img && sync
cd ${GITHUB_ACTION_PATH}
echo -e "Output environment variables."
echo "PACKAGED_OUTPUTPATH=${PWD}/${armbian_filepath}" >> $GITHUB_ENV
echo "PACKAGED_OUTPUTDATE=$(date +"%Y.%m.%d.%H%M")" >> $GITHUB_ENV
echo "PACKAGED_STATUS=success" >> $GITHUB_ENV
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${armbian_filepath}"
echo -e "PACKAGED_OUTPUTDATE: $(date +"%Y.%m.%d.%H%M")"
echo -e "PACKAGED_STATUS: success"
echo -e "PACKAGED_OUTPUTPATH files list:"
echo -e "$(ls ${PWD}/${armbian_filepath} 2>/dev/null) \n"
elif [ "${build_target}" == "kernel" ]; then
cd ${GITHUB_ACTION_PATH}
echo -e "Start compile kernel..."
config_filepath="compile-kernel/tools/config"
kernel_outpath="compile-kernel/output"
if [[ -n "${{ inputs.kernel_config }}" ]]; then
if [[ "$(ls ${GITHUB_WORKSPACE}/${{ inputs.kernel_config }}/config-* -l 2>/dev/null | grep "^-" | wc -l)" -ne "0" ]]; then
echo -e "Use a custom kernel compilation template."
rm -f ${config_filepath}/* 2>/dev/null && sync
sudo cp -f ${GITHUB_WORKSPACE}/${{ inputs.kernel_config }}/config-* ${config_filepath}/ 2>/dev/null && sync
echo -e "List of Kernel Custom Compilation Configuration Templates: \n$(ls ${config_filepath})"
else
echo -e "The custom kernel compilation template path is invalid, continue to use the default template."
fi
else
echo -e "Use the default kernel compilation template."
fi
make_command=" -d"
[ -n ${{ inputs.kernel_repo }} ] && make_command="${make_command} -r ${{ inputs.kernel_repo }}"
[ -n ${{ inputs.kernel_version }} ] && make_command="${make_command} -k ${{ inputs.kernel_version }}"
[ -n ${{ inputs.kernel_auto }} ] && make_command="${make_command} -a ${{ inputs.kernel_auto }}"
[ -n ${{ inputs.kernel_sign }} ] && make_command="${make_command} -n ${{ inputs.kernel_sign }}"
sudo chmod +x recompile
sudo ./recompile ${make_command}
echo -e "The kernel files in the [ ${kernel_outpath} ] directory. \n"
cd ${GITHUB_ACTION_PATH}
output_tags="$(ls ${PWD}/${kernel_outpath}/*.tar.gz -l | awk '{print $9}' | grep -oE '[1-9].[0-9]{1,3}.[0-9]+' | xargs | tr "[ ]" "_")"
echo -e "Output environment variables."
echo "PACKAGED_OUTPUTTAGS=${output_tags}" >> $GITHUB_ENV
echo "PACKAGED_OUTPUTPATH=${PWD}/${kernel_outpath}" >> $GITHUB_ENV
echo "PACKAGED_OUTPUTDATE=$(date +"%Y.%m.%d.%H%M")" >> $GITHUB_ENV
echo "PACKAGED_STATUS=success" >> $GITHUB_ENV
echo -e "PACKAGED_OUTPUTTAGS: ${output_tags}"
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${kernel_outpath}"
echo -e "PACKAGED_OUTPUTDATE: $(date +"%Y.%m.%d.%H%M")"
echo -e "PACKAGED_STATUS: success"
echo -e "PACKAGED_OUTPUTPATH files list:"
echo -e "$(ls ${PWD}/${kernel_outpath} 2>/dev/null) \n"
else
echo -e "Please select a build target: armbian / kernel"
exit 1
fi
branding:
icon: "terminal"
color: "gray-dark"