-
Notifications
You must be signed in to change notification settings - Fork 1.3k
119 lines (104 loc) · 4.41 KB
/
Copy pathdata.yml
File metadata and controls
119 lines (104 loc) · 4.41 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
#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: Data
on:
release:
types:
- created
workflow_dispatch:
inputs:
data:
description: "models, pats, addons, modules, modules_detailed"
default: "11111"
type: string
push:
description: "push"
default: false
type: boolean
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
with:
ref: main
- name: Init Env
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Get Data
run: |
REPO="${{ github.server_url }}/${{ github.repository }}"
PRERELEASE="true"
TAG=""
for i in {1..3}; do
if [ "${PRERELEASE}" = "true" ]; then
TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep "/refs/tags/.*\.zip" | sed -E 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/' | sort -rV | head -1 | sed 's/^[v|V]//g')"
else
TAG="$(curl -skL --connect-timeout 10 -w "%{url_effective}" -o /dev/null "${REPO}/releases/latest" | awk -F'/' '{print $NF}' | sed 's/^[v|V]//g')"
fi
rm -f rr-${TAG}.img.zip
STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/rr-${TAG}.img.zip" -o "rr-${TAG}.img.zip")
if [ $? -eq 0 ] && [ ${STATUS:-0} -eq 200 ]; then
break
else
echo "Download failed, retry $i/3"
sleep 60
fi
done
if [ ! -f "rr-${TAG}.img.zip" ] || [ ${STATUS:-0} -ne 200 ]; then
echo "Download failed after 3 attempts"
exit 1
fi
unzip rr-${TAG}.img.zip -d rr rr.img
sudo apt update
sudo apt install -y locales busybox dialog gettext sed gawk jq curl
sudo apt install -y python-is-python3 python3-pip libelf-dev qemu-utils cpio xz-utils lz4 lzma bzip2 gzip zstd
sudo apt install -y build-essential libtool pkgconf libzstd-dev liblzma-dev libssl-dev # kmodule dependencies
# Backup the original python3 executable.
sudo mv -f "$(realpath $(which python3))/EXTERNALLY-MANAGED" "$(realpath $(which python3))/EXTERNALLY-MANAGED.bak" 2>/dev/null || true
sudo pip3 install -U -r scripts/requirements.txt
. scripts/func.sh "${{ secrets.RRORG }}"
LOOPX=$(sudo losetup -f)
sudo losetup -P "${LOOPX}" "rr/rr.img"
rm -rf "/tmp/mnt/p3"
mkdir -p "/tmp/mnt/p3"
sudo mount "${LOOPX}p3" "/tmp/mnt/p3"
unpackInitrd /tmp/mnt/p3/initrd-rr "rr/initrd"
[ -n "${{ inputs.data }}" ] && DATA="${{ inputs.data }}" || DATA="11111"
echo "DATA=${DATA}"
[ "${DATA:0:1}" = "1" ] && python3 scripts/func.py getmodels -w "rr/initrd" -j "docs/models.json" -x "docs/models.xlsx"
[ "${DATA:1:1}" = "1" ] && python3 scripts/func.py getpats -w "rr/initrd" -j "docs/pats.json" -x "docs/pats.xlsx"
[ "${DATA:2:1}" = "1" ] && python3 scripts/func.py getaddons -w "/tmp" -j "docs/addons.json" -x "docs/addons.xlsx"
[ "${DATA:3:1}" = "1" ] && python3 scripts/func.py getmodules -w "/tmp" -j "docs/modules.json" -x "docs/modules.xlsx"
[ "${DATA:4:1}" = "1" ] && python3 scripts/func.py getmodules -w "/tmp" -j "docs/modules_detailed.json" -x "docs/modules_detailed.xlsx" -d
sudo umount "/tmp/mnt/p3"
sudo losetup -d "${LOOPX}"
rm -rf "/tmp/mnt/p3"
- name: Upload to Artifacts
if: success()
uses: actions/upload-artifact@v7
with:
name: docs
path: |
docs/*.json
docs/*.xlsx
retention-days: 5
- name: Check and Push
if: success() && (inputs.push == true || github.event.action == 'created')
run: |
echo "Git push ..."
# git checkout main
git pull
status=$(git status -s | grep -E "docs" | awk '{printf " %s", $2}')
if [ -n "${status}" ]; then
git add ${status}
git commit -m "update $(date +%Y-%m-%d" "%H:%M:%S)"
git push -f
fi