From 76abc09d2d9a8ddf9627114cc808ca12518fceeb Mon Sep 17 00:00:00 2001 From: Ing Date: Wed, 3 Apr 2024 05:55:20 +0800 Subject: [PATCH] add version for custom --- .github/workflows/data.yml | 56 ++++++++++++++++++++++ .github/workflows/issues.yml | 20 +++++--- docs/issues.html | 90 +++++++++++++++++------------------- localbuild.sh | 4 +- 4 files changed, 114 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/data.yml diff --git a/.github/workflows/data.yml b/.github/workflows/data.yml new file mode 100644 index 00000000..a9fb1111 --- /dev/null +++ b/.github/workflows/data.yml @@ -0,0 +1,56 @@ +# +# Copyright (C) 2022 Ing +# +# This is free software, licensed under the MIT License. +# See /LICENSE for more information. +# + +name: Data +on: + workflow_dispatch: + inputs: + push: + description: "push" + default: false + type: boolean + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@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 models + run: | + models="{" + WORK_PATH="files/initrd/opt/rr" + for M in $(find "${WORK_PATH}/model-configs" -maxdepth 1 -name \*.yml 2>/dev/null | sed 's/.*\///; s/\.yml//'); do + models+="\"${M}\":[" + for V in $(yq eval '.productvers | explode(.) | to_entries | map([.key])[] | .[]' "${WORK_PATH}/model-configs/${M}.yml" 2>/dev/null | sort -r); do + models+="\"${V}\"," + done + models="${models%,}]," + done + models="${models%,}}" + echo "${models}" >docs/models.json + + - name: Check and Push + if: success() && inputs.push == true + run: | + echo "Git push ..." + git pull + status=$(git status -s | grep -E 'docs/models.json' | 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 + + \ No newline at end of file diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index a82c6126..92f27876 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -5,7 +5,7 @@ # See /LICENSE for more information. # -name: Auto Comment +name: Issues on: issues: types: [opened, reopened] @@ -36,14 +36,17 @@ jobs: iscustom = 'false' warinfo = 'false' - model = '' + language= '' + model = '' + version = '' try: if issuetitle.lower().startswith('custom'): jsonbody = json.loads(issuebody) iscustom = 'true' - model = jsonbody.get('model', '') language = jsonbody.get('language', '') + model = jsonbody.get('model', '') + version = jsonbody.get('version', '') except ValueError as e: pass @@ -53,8 +56,10 @@ jobs: set_output("iscustom", iscustom) set_output("warinfo", warinfo) - set_output("model", model) + set_output("language", language) + set_output("model", model) + set_output("version", version) - name: Update Comment Warinfo if: env.warinfo == 'true' @@ -126,8 +131,9 @@ jobs: run: | # 累了, 毁灭吧! - REPO=${{ github.server_url }}/${{ github.repository }} - MODEL=${{ env.model }} + REPO="${{ github.server_url }}/${{ github.repository }}" + MODEL="${{ env.model }}" + VERSION="${{ env.version }}" PRERELEASE="false" TAG="" @@ -161,7 +167,7 @@ jobs: [ -n "${{ env.language }}" ] && echo "${{ env.language }}.UTF-8" | sudo tee rr/ws/mnt/p1/.locale - sudo ./localbuild.sh config ${MODEL} + sudo ./localbuild.sh config "${MODEL}" "${VERSION}" if [ $? -ne 0 ]; then echo "config failed" exit 1 diff --git a/docs/issues.html b/docs/issues.html index 11386da1..2c7dc19c 100644 --- a/docs/issues.html +++ b/docs/issues.html @@ -33,16 +33,45 @@ var repo = "RROrg/rr" + function httpGetAsync(theUrl, callback) { + let xmlHttpReq = new XMLHttpRequest(); + xmlHttpReq.onreadystatechange = function () { + if (xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200) + callback(xmlHttpReq.responseText); + }; + xmlHttpReq.open("GET", theUrl, true); // true for asynchronous + xmlHttpReq.send(null); + } + window.onload = function () { init(); } function init() { - $("#model").on("change", changeModel); - changeModel(); + httpGetAsync("https://raw.githubusercontent.com/RROrg/rr/main/docs/models.json", function (result) { + _modules = JSON.parse(result); + $("#model").on("change", changeModel); + setModels(); + }); } + function setModels() { + var models = Object.keys(_modules).sort(); + $("#model")[0].options.length = 0; + for (var i = 0; i < models.length; i++) { + var model = models[i]; + $("#model").append(``); + } + changeModel(); + } function changeModel() { + model = $("#model").val(); + var versions = _modules[model]; + $("#version")[0].options.length = 0; + for (var i = 0; i < versions.length; i++) { + var version = versions[i]; + $("#version").append(``); + } changeproductsimage(); } @@ -58,7 +87,7 @@ let formData = new FormData(form); var title = "custom"; var body = {}; - var _parameters = ["title", "language", "model"]; + var _parameters = ["title", "language", "model", "version"]; for (var key in _parameters) { var name = _parameters[key]; if (name == "title") { @@ -151,54 +180,21 @@
+
+
+ +
+
+ +
+