forked from ophub/amlogic-s9xxx-openwrt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
103 lines (96 loc) · 4.23 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
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 armvirt64 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_5.15.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: ""
builder_name:
description: "Set OpenWrt builder signature."
required: false
default: ""
runs:
using: "composite"
steps:
- shell: bash
run: |
cd ${GITHUB_ACTION_PATH}
echo -e "ophub package actions path: [ ${PWD} ]"
openwrt_filename="${{ inputs.openwrt_path }}"
openwrt_savefile="${openwrt_filename##*/}"
openwrt_savepath="openwrt-armvirt"
openwrt_outpath="openwrt/out"
echo -e "Get openwrt file input parameters: [ ${openwrt_filename} ]"
[[ -z "${openwrt_filename}" ]] && echo -e "The [ openwrt_path ] variable must be specified." && exit 1
[[ -d "${openwrt_savepath}" ]] || mkdir -p ${openwrt_savepath}
[[ -d "${openwrt_outpath}" ]] || mkdir -p ${openwrt_outpath}
if [[ "${openwrt_filename}" == http* ]]; then
echo -e "Download 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 "Copy OpenWrt rootfs file: [ ${openwrt_filename} ]"
cp -vf ${GITHUB_WORKSPACE}/${openwrt_filename} ${openwrt_savepath} 2>/dev/null
else
echo -e "The [ ${openwrt_savepath}/${openwrt_savefile} ] file already exists, skipping."
fi
fi
sync
echo -e "About the [ ${openwrt_savepath} ] directory: \n$(ls -l ${openwrt_savepath} 2>/dev/null)"
cd ${GITHUB_ACTION_PATH}
echo -e "Start to make openwrt..."
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_size }}" ]] && make_command="${make_command} -s ${{ inputs.openwrt_size }}"
[[ -n "${{ inputs.builder_name }}" ]] && make_command="${make_command} -n ${{ inputs.builder_name }}"
sudo ./remake ${make_command}
cd ${GITHUB_ACTION_PATH}/${openwrt_outpath}
# Generate a sha256sum verification file for each OpenWrt image file
for file in *; do [[ -f "${file}" ]] && sha256sum "${file}" >"${file}.sha" 2>/dev/null; done
rm -f *.sha.sha 2>/dev/null
sync && sleep 3
cd ${GITHUB_ACTION_PATH}
echo -e "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 list: \n$(ls -l ${PWD}/${openwrt_outpath} 2>/dev/null)"
branding:
icon: "terminal"
color: "gray-dark"