update token (#3076)

* update token

* select package by random
pull/3081/head
ruki 11 months ago committed by GitHub
parent e0ca2fa6fe
commit 484c22ab06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .github/workflows/autoupdate.yml
  2. 6
      scripts/autoupdate.lua

@ -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 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 update
sudo apt install -y gh unzip zip 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 "waruqi@gmail.com" git config --global user.email "waruqi@gmail.com"
git config --global user.name "ruki" git config --global user.name "ruki"
@ -37,6 +37,6 @@ jobs:
- name: Auto-update packages - name: Auto-update packages
run: | run: |
xmake l -vD scripts/autoupdate.lua 1 xmake l -vD scripts/autoupdate.lua 3

@ -94,12 +94,14 @@ function main(maxcount)
local count = 0 local count = 0
local maxcount = tonumber(maxcount or 10) local maxcount = tonumber(maxcount or 10)
local instances = _get_all_packages() 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") local checkupdate_filepath = path.join(instance:scriptdir(), "checkupdate.lua")
if not os.isfile(checkupdate_filepath) then if not os.isfile(checkupdate_filepath) then
checkupdate_filepath = path.join(os.scriptdir(), "checkupdate.lua") checkupdate_filepath = path.join(os.scriptdir(), "checkupdate.lua")
end 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 checkupdate = import("checkupdate", {rootdir = path.directory(checkupdate_filepath), anonymous = true})
local version, shasum = checkupdate(instance) local version, shasum = checkupdate(instance)
if version and shasum and not _is_pending(instance, version) then if version and shasum and not _is_pending(instance, version) then

Loading…
Cancel
Save