Browse Source

update token (#3076)

* update token

* select package by random
ruki 1 year ago
parent
commit
484c22ab06
2 changed files with 6 additions and 4 deletions
  1. 2 2
      .github/workflows/autoupdate.yml
  2. 4 2
      scripts/autoupdate.lua

+ 2 - 2
.github/workflows/autoupdate.yml

@@ -24,7 +24,7 @@ jobs:
           echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
           sudo apt update
           sudo apt install -y gh unzip zip
-          echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
+          echo ${{ secrets.XMAKE_REPO_TOKEN }} | gh auth login --with-token
           git config --global user.email "[email protected]"
           git config --global user.name "ruki"
 
@@ -37,6 +37,6 @@ jobs:
 
       - name: Auto-update packages
         run: |
-          xmake l -vD scripts/autoupdate.lua 1
+          xmake l -vD scripts/autoupdate.lua 3
 
 

+ 4 - 2
scripts/autoupdate.lua

@@ -94,12 +94,14 @@ function main(maxcount)
     local count = 0
     local maxcount = tonumber(maxcount or 10)
     local instances = _get_all_packages()
-    for _, instance in ipairs(instances) do
+    math.randomseed(os.time())
+    while count < maxcount do
+        local instance = instances[math.random(#instances)]
         local checkupdate_filepath = path.join(instance:scriptdir(), "checkupdate.lua")
         if not os.isfile(checkupdate_filepath) then
             checkupdate_filepath = path.join(os.scriptdir(), "checkupdate.lua")
         end
-        if os.isfile(checkupdate_filepath) and count < maxcount then
+        if os.isfile(checkupdate_filepath) then
             local checkupdate = import("checkupdate", {rootdir = path.directory(checkupdate_filepath), anonymous = true})
             local version, shasum = checkupdate(instance)
             if version and shasum and not _is_pending(instance, version) then