-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathaction.yml
More file actions
129 lines (121 loc) · 5.49 KB
/
action.yml
File metadata and controls
129 lines (121 loc) · 5.49 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
name: "Make OpenWrt"
author: "https://github.com/ophub/amlogic-s9xxx-openwrt"
description: "Support Amlogic, Rockchip and Allwinner boxes."
inputs:
mode:
description: "Select script."
required: false
default: "ophub"
openwrt_path:
description: "Select armsr-armv8 file path."
required: false
default: "openwrt/bin/targets/*/*/*rootfs.tar.gz"
openwrt_board:
description: "Select device board."
required: false
default: "all"
kernel_repo:
description: "Select kernel repository."
required: false
default: "ophub/kernel"
kernel_usage:
description: "Set the tags of the stable kernel."
required: false
default: "stable"
openwrt_kernel:
description: "Select kernel version."
required: false
default: "6.1.y_6.12.y"
auto_kernel:
description: "Auto use the latest kernel."
required: false
default: "true"
openwrt_size:
description: "Set the rootfs size(Unit: MiB)."
required: false
default: ""
openwrt_ip:
description: "Set the rootfs IP address."
required: false
default: "192.168.1.1"
openwrt_files:
description: "Add custom OpenWrt files."
required: false
default: ""
builder_name:
description: "Set OpenWrt builder signature."
required: false
default: ""
runs:
using: "composite"
steps:
- shell: bash
run: |
cd ${{ github.action_path }}
echo -e "Action workspace path: [ ${PWD} ]"
openwrt_filename="${{ inputs.openwrt_path }}"
openwrt_savefile="${openwrt_filename##*/}"
openwrt_savepath="openwrt-armsr"
openwrt_outpath="openwrt/out"
echo -e "OpenWrt rootfs input path: [ ${openwrt_filename} ]"
[[ -z "${openwrt_filename}" ]] && echo -e "The [ openwrt_path ] parameter is required but not specified." && exit 1
[[ -d "${openwrt_savepath}" ]] || mkdir -p ${openwrt_savepath}
[[ -d "${openwrt_outpath}" ]] || mkdir -p ${openwrt_outpath}
if [[ "${openwrt_filename}" =~ ^http ]]; then
echo -e "Downloading OpenWrt rootfs file: [ ${openwrt_filename} ]"
curl -fsSL "${openwrt_filename}" -o "${openwrt_savepath}/${openwrt_savefile}"
else
if [[ -z "$(ls ${openwrt_savepath}/${openwrt_savefile} 2>/dev/null)" ]]; then
echo -e "Copying OpenWrt rootfs file: [ ${openwrt_filename} ]"
if [[ "${openwrt_filename}" =~ ^/ ]]; then
cp -vf ${openwrt_filename} -t ${openwrt_savepath}/ || true
else
cp -vf ${{ github.workspace }}/${openwrt_filename} -t ${openwrt_savepath}/ || true
fi
else
echo -e "The [ ${openwrt_savepath}/${openwrt_savefile} ] file already exists, skipping."
fi
fi
sync
echo -e "Contents of the [ ${openwrt_savepath} ] directory: \n$(ls -lh ${openwrt_savepath} 2>/dev/null)"
# Apply custom OpenWrt files
if [[ -n "${{ inputs.openwrt_files }}" && "${{ inputs.openwrt_files }}" != "false" ]]; then
echo -e "Applying custom OpenWrt files..."
copy_from_path="${{ inputs.openwrt_files }}"
copy_from_path="${copy_from_path%/}"
[[ "${copy_from_path}" != /* ]] && copy_from_path="${{ github.workspace }}/${copy_from_path}"
copy_to_path="make-openwrt/openwrt-files/common-files"
cp -avf --no-preserve=ownership "${copy_from_path}/." -t "${copy_to_path}/" || true
else
echo -e "Using the default OpenWrt files."
fi
cd ${{ github.action_path }}
echo -e "Starting OpenWrt build process..."
make_command=""
[[ -n "${{ inputs.openwrt_board }}" ]] && make_command="${make_command} -b ${{ inputs.openwrt_board }}"
[[ -n "${{ inputs.kernel_repo }}" ]] && make_command="${make_command} -r ${{ inputs.kernel_repo }}"
[[ -n "${{ inputs.kernel_usage }}" ]] && make_command="${make_command} -u ${{ inputs.kernel_usage }}"
[[ -n "${{ inputs.openwrt_kernel }}" ]] && make_command="${make_command} -k ${{ inputs.openwrt_kernel }}"
[[ -n "${{ inputs.auto_kernel }}" ]] && make_command="${make_command} -a ${{ inputs.auto_kernel }}"
[[ -n "${{ inputs.openwrt_ip }}" ]] && make_command="${make_command} -p ${{ inputs.openwrt_ip }}"
[[ -n "${{ inputs.openwrt_size }}" ]] && make_command="${make_command} -s ${{ inputs.openwrt_size }}"
[[ -n "${{ inputs.builder_name }}" ]] && make_command="${make_command} -n ${{ inputs.builder_name }}"
read -r -a make_args <<< "${make_command}"
sudo ./remake "${make_args[@]}"
cd ${{ github.action_path }}
# Copy OpenWrt rootfs.tar.gz file to the output directory
echo -e "Contents of the [ ${openwrt_savepath} ] directory: \n$(ls -lh ${openwrt_savepath} 2>/dev/null)"
sudo cp -vf ${openwrt_savepath}/${openwrt_savefile} -t ${openwrt_outpath}/ || true
sync && sleep 3
cd ${{ github.action_path }}
echo -e "Setting output environment variables."
echo "PACKAGED_OUTPUTPATH=${PWD}/${openwrt_outpath}" >> ${GITHUB_ENV}
echo "PACKAGED_OUTPUTDATE=$(date +"%m.%d.%H%M")" >> ${GITHUB_ENV}
echo "PACKAGED_STATUS=success" >> ${GITHUB_ENV}
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${openwrt_outpath}"
echo -e "PACKAGED_OUTPUTDATE: $(date +"%m.%d.%H%M")"
echo -e "PACKAGED_STATUS: success"
echo -e "PACKAGED_OUTPUTPATH files: \n$(ls -lh ${PWD}/${openwrt_outpath}/ 2>/dev/null)"
branding:
icon: "terminal"
color: "gray-dark"