forked from ophub/amlogic-s9xxx-openwrt
-
Notifications
You must be signed in to change notification settings - Fork 10
/
action.yml
99 lines (92 loc) · 4.01 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
name: "Use ophub script to package Armvirt as OpenWrt"
author: "ophub"
description: "Package Armvirt as OpenWrt. Support Amlogic s9xxx tv box."
inputs:
mode:
description: "Choose script."
required: false
default: "ophub"
openwrt_path:
description: "Choose armvirt64 file path."
required: false
default: "openwrt/bin/targets/*/*/*rootfs.tar.gz"
openwrt_board:
description: "Choose Amlogic board."
required: false
default: "s905d_s905x3"
openwrt_kernel:
description: "Choose kernel version."
required: false
default: "5.10.125_5.15.50"
auto_kernel:
description: "Auto use the latest kernel."
required: false
default: "true"
version_branch:
description: "Choose version branch."
required: false
default: "stable"
kernel_repo:
description: "Choose kernel repository."
required: false
default: "https://github.com/ophub/kernel/tree/main/pub"
openwrt_size:
description: "Set the rootfs size(Unit: MiB)."
required: false
default: "1024"
gh_token:
description: "Set the token."
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_savepath="openwrt-armvirt"
openwrt_outpath="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 "Use wget to download file: [ ${openwrt_filename} ]"
wget ${openwrt_filename} -q -P ${openwrt_savepath} 2>/dev/null
else
echo -e "Copy OpenWrt rootfs file: [ ${openwrt_filename} ]"
cp -vf ${GITHUB_WORKSPACE}/${openwrt_filename} ${openwrt_savepath} 2>/dev/null
# If the .config file exists, save it to the out directory
config_file="${GITHUB_WORKSPACE}/${openwrt_filename%%/*}/.config"
[[ -s "${config_file}" ]] && {
echo -e "Copy OpenWrt .config file: [ ${config_file} ]"
cp -vf ${config_file} ${openwrt_outpath}/config 2>/dev/null
}
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.openwrt_kernel }}" ]] && make_command="${make_command} -k ${{ inputs.openwrt_kernel }}"
[[ -n "${{ inputs.auto_kernel }}" ]] && make_command="${make_command} -a ${{ inputs.auto_kernel }}"
[[ -n "${{ inputs.version_branch }}" ]] && make_command="${make_command} -v ${{ inputs.version_branch }}"
[[ -n "${{ inputs.kernel_repo }}" ]] && make_command="${make_command} -r ${{ inputs.kernel_repo }}"
[[ -n "${{ inputs.openwrt_size }}" ]] && make_command="${make_command} -s ${{ inputs.openwrt_size }}"
[[ -n "${{ inputs.gh_token }}" ]] && make_command="${make_command} -g ${{ inputs.gh_token }}"
sudo ./make ${make_command}
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"