From db40906e2d24c70bdd2e6cf9312fdb2b58712024 Mon Sep 17 00:00:00 2001 From: easterNday <849919718@qq.com> Date: Thu, 8 Jun 2023 08:55:08 +0800 Subject: [PATCH] download: enable ghproxy --- .github/workflows/debug.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/del.yml | 8 ++++---- .github/workflows/release.yml | 6 ------ box/scripts/box.tool | 20 ++++++++++++++++++++ 4 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/debug.yml diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml new file mode 100644 index 0000000..d119476 --- /dev/null +++ b/.github/workflows/debug.yml @@ -0,0 +1,31 @@ +name: debug + +on: + workflow_dispatch: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Get Version + id: get_version + run: | + echo "version=$(grep -oP 'version=\K[^ ]+' module.prop)" >> "$GITHUB_OUTPUT" + echo "date=$(date +%Y%m%d)" >> "$GITHUB_OUTPUT" + + - name: Generate Asset + run: | + sudo mkdir -p /box_for_root + sudo cp -r --parents $(find ./ -type f ! -path './.git/*' ! -name 'CHANGELOG.md' ! -name 'update.json' ! -name 'build.sh' ! -path './.github/*' ! -path './docs/*') /box_for_root/ + + - name: Upload Debug Asset => (box_for_magisk_${{ steps.get_version.outputs.version }}_$(date +%Y%m%d)) + uses: actions/upload-artifact@v3 + with: + name: "box_for_magisk_${{ steps.get_version.outputs.version }}_${{ steps.get_version.outputs.date }}" + path: /box_for_root/ diff --git a/.github/workflows/del.yml b/.github/workflows/del.yml index 5b2439e..f2861f6 100755 --- a/.github/workflows/del.yml +++ b/.github/workflows/del.yml @@ -1,17 +1,17 @@ name: Delete old workflow runs -description: This workflow deletes old workflow runs to maintain a clean workflow history. + on: workflow_dispatch: - + jobs: delete_old_runs: runs-on: ubuntu-latest steps: - name: Delete workflow runs uses: Mattraks/delete-workflow-runs@v2 - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/master' with: token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.repository }} retain_days: 0 - keep_minimum_runs: 0 \ No newline at end of file + keep_minimum_runs: 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index edb7ed3..7d621b3 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,12 +16,6 @@ jobs: - name: run build.sh run: sh build.sh - - name: Upload Release Asset - uses: actions/upload-artifact@v2 - with: - name: box_for_magisk - path: box_for_root-v*.zip - - name: Create GitHub Release uses: softprops/action-gh-release@v1 with: diff --git a/box/scripts/box.tool b/box/scripts/box.tool index 0fe6beb..2fbff67 100755 --- a/box/scripts/box.tool +++ b/box/scripts/box.tool @@ -12,6 +12,9 @@ dev=true # option to download Singbox kernel beta or release singbox_releases=false +# whether use ghproxy to accelerate github download +use_ghproxy=false + # Check internet connection with mlbox check_connection_with_mlbox() { now=$(date +"%R") @@ -106,6 +109,23 @@ update_file() { if [ -f "${file}" ]; then mv "${file}" "${file_bak}" || return 1 fi + # Enable ghproxy to accelerate download + if [[ "$use_ghproxy" == false ]] && ([[ "$update_url" == "https://github.com/"* ]] || [[ "$update_url" == "https://raw.githubusercontent.com/"* ]] || [[ "$update_url" == "https://gist.github.com/"* ]] || [[ "$update_url" == "https://gist.githubusercontent.com/"* ]]); then + echo "- It seems that you are downloading from GitHub." + echo "- Do you want to use the GitHub proxy service to download?" + echo "- [ Vol UP: Yes ]" + echo "- [ Vol DOWN: No ]" + while true; do + getevent -lc 1 2>&1 | grep -q KEY_VOLUMEUP && { + use_ghproxy=true + break + } + getevent -lc 1 2>&1 | grep -q KEY_VOLUMEDOWN && break + done + fi + if [[ "$use_ghproxy" == true ]]; then + update_url="https://ghproxy.com/${update_url}" + fi request="busybox wget" request+=" --no-check-certificate" request+=" --user-agent ${user_agent}"