avoid github api rate limits in update workflows

This commit is contained in:
2026-03-09 17:33:45 +00:00
parent 1b63847315
commit 1dfe28047c
3 changed files with 113 additions and 65 deletions
+30 -15
View File
@@ -35,15 +35,10 @@ jobs:
PY PY
) )
latest_version=$(python - <<'PY' latest_version=$(curl -fsSLI -o /dev/null -w '%{url_effective}' \
import json, urllib.request 'https://github.com/cjpais/Handy/releases/latest' \
url='https://api.github.com/repos/cjpais/Handy/releases/latest' | sed -E 's#.*/##' \
with urllib.request.urlopen(url) as r: | sed 's/^v//')
data=json.load(r)
tag=data.get('tag_name','').lstrip('v')
print(tag)
PY
)
echo "current=$current_version" echo "current=$current_version"
echo "latest=$latest_version" echo "latest=$latest_version"
@@ -110,16 +105,36 @@ jobs:
fi fi
echo "Creating PR..." echo "Creating PR..."
curl -sS -X POST \ created="false"
for head in "${branch}" "thomas:${branch}"; do
echo "Trying head=${head}"
response=$(curl -sS -w '\n%{http_code}' -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
"${api}/pulls" \ "${api}/pulls" \
-d "$(cat <<JSON -d "$(cat <<JSON
{ {
\"title\": \"update handy to ${{ steps.update.outputs.version }}\", "title": "update handy to ${{ steps.update.outputs.version }}",
\"head\": \"${branch}\", "head": "${head}",
\"base\": \"main\", "base": "main",
\"body\": \"automated update of handy appimage version and hash\" "body": "automated update of handy appimage version and hash"
} }
JSON JSON
)" )")
body=$(printf '%s\n' "$response" | sed '$d')
code=$(printf '%s\n' "$response" | tail -n1)
echo "Create PR status: $code"
echo "$body"
if [ "$code" -ge 200 ] && [ "$code" -lt 300 ]; then
created="true"
break
fi
done
if [ "$created" != "true" ]; then
echo "PR creation failed"
exit 1
fi
+31 -15
View File
@@ -36,15 +36,10 @@ jobs:
PY PY
) )
latest_version=$(python - <<'PY' latest_version=$(curl -fsSLI -o /dev/null -w '%{url_effective}' \
import json, urllib.request 'https://github.com/imputnet/helium-linux/releases/latest' \
url='https://api.github.com/repos/imputnet/helium-linux/releases/latest' | sed -E 's#.*/##' \
with urllib.request.urlopen(url) as r: | sed 's/^v//')
data=json.load(r)
tag=data.get('tag_name','').lstrip('v')
print(tag)
PY
)
echo "current=$current_version" echo "current=$current_version"
echo "latest=$latest_version" echo "latest=$latest_version"
@@ -110,16 +105,37 @@ jobs:
exit 0 exit 0
fi fi
curl -fsS -X POST \ echo "Creating PR..."
created="false"
for head in "${branch}" "thomas:${branch}"; do
echo "Trying head=${head}"
response=$(curl -sS -w '\n%{http_code}' -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
"${api}/pulls" \ "${api}/pulls" \
-d "$(cat <<JSON -d "$(cat <<JSON
{ {
\"title\": \"update helium to ${{ steps.update.outputs.version }}\", "title": "update helium to ${{ steps.update.outputs.version }}",
\"head\": \"${branch}\", "head": "${head}",
\"base\": \"main\", "base": "main",
\"body\": \"automated update of helium appimage version and hash\" "body": "automated update of helium appimage version and hash"
} }
JSON JSON
)" )")
body=$(printf '%s\n' "$response" | sed '$d')
code=$(printf '%s\n' "$response" | tail -n1)
echo "Create PR status: $code"
echo "$body"
if [ "$code" -ge 200 ] && [ "$code" -lt 300 ]; then
created="true"
break
fi
done
if [ "$created" != "true" ]; then
echo "PR creation failed"
exit 1
fi
+31 -14
View File
@@ -35,14 +35,10 @@ jobs:
PY PY
) )
latest_version=$(python - <<'PY' latest_version=$(curl -fsSLI -o /dev/null -w '%{url_effective}' \
import json, urllib.request 'https://github.com/zen-browser/desktop/releases/latest' \
url='https://api.github.com/repos/zen-browser/desktop/releases/latest' | sed -E 's#.*/##' \
with urllib.request.urlopen(url) as r: | sed 's/^v//')
data=json.load(r)
print(data.get('tag_name','').lstrip('v'))
PY
)
echo "current=$current_version" echo "current=$current_version"
echo "latest=$latest_version" echo "latest=$latest_version"
@@ -107,16 +103,37 @@ jobs:
exit 0 exit 0
fi fi
curl -fsS -X POST \ echo "Creating PR..."
created="false"
for head in "${branch}" "thomas:${branch}"; do
echo "Trying head=${head}"
response=$(curl -sS -w '\n%{http_code}' -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
"${api}/pulls" \ "${api}/pulls" \
-d "$(cat <<JSON -d "$(cat <<JSON
{ {
\"title\": \"update zen browser to ${{ steps.update.outputs.version }}\", "title": "update zen browser to ${{ steps.update.outputs.version }}",
\"head\": \"${branch}\", "head": "${head}",
\"base\": \"main\", "base": "main",
\"body\": \"automated update of zen browser appimage version and hash\" "body": "automated update of zen browser appimage version and hash"
} }
JSON JSON
)" )")
body=$(printf '%s\n' "$response" | sed '$d')
code=$(printf '%s\n' "$response" | tail -n1)
echo "Create PR status: $code"
echo "$body"
if [ "$code" -ge 200 ] && [ "$code" -lt 300 ]; then
created="true"
break
fi
done
if [ "$created" != "true" ]; then
echo "PR creation failed"
exit 1
fi