avoid github api rate limits in update workflows
This commit is contained in:
@@ -35,15 +35,10 @@ jobs:
|
||||
PY
|
||||
)
|
||||
|
||||
latest_version=$(python - <<'PY'
|
||||
import json, urllib.request
|
||||
url='https://api.github.com/repos/cjpais/Handy/releases/latest'
|
||||
with urllib.request.urlopen(url) as r:
|
||||
data=json.load(r)
|
||||
tag=data.get('tag_name','').lstrip('v')
|
||||
print(tag)
|
||||
PY
|
||||
)
|
||||
latest_version=$(curl -fsSLI -o /dev/null -w '%{url_effective}' \
|
||||
'https://github.com/cjpais/Handy/releases/latest' \
|
||||
| sed -E 's#.*/##' \
|
||||
| sed 's/^v//')
|
||||
|
||||
echo "current=$current_version"
|
||||
echo "latest=$latest_version"
|
||||
@@ -110,16 +105,36 @@ jobs:
|
||||
fi
|
||||
|
||||
echo "Creating PR..."
|
||||
curl -sS -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${api}/pulls" \
|
||||
-d "$(cat <<JSON
|
||||
{
|
||||
\"title\": \"update handy to ${{ steps.update.outputs.version }}\",
|
||||
\"head\": \"${branch}\",
|
||||
\"base\": \"main\",
|
||||
\"body\": \"automated update of handy appimage version and hash\"
|
||||
}
|
||||
JSON
|
||||
)"
|
||||
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 "Content-Type: application/json" \
|
||||
"${api}/pulls" \
|
||||
-d "$(cat <<JSON
|
||||
{
|
||||
"title": "update handy to ${{ steps.update.outputs.version }}",
|
||||
"head": "${head}",
|
||||
"base": "main",
|
||||
"body": "automated update of handy appimage version and hash"
|
||||
}
|
||||
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
|
||||
|
||||
@@ -36,15 +36,10 @@ jobs:
|
||||
PY
|
||||
)
|
||||
|
||||
latest_version=$(python - <<'PY'
|
||||
import json, urllib.request
|
||||
url='https://api.github.com/repos/imputnet/helium-linux/releases/latest'
|
||||
with urllib.request.urlopen(url) as r:
|
||||
data=json.load(r)
|
||||
tag=data.get('tag_name','').lstrip('v')
|
||||
print(tag)
|
||||
PY
|
||||
)
|
||||
latest_version=$(curl -fsSLI -o /dev/null -w '%{url_effective}' \
|
||||
'https://github.com/imputnet/helium-linux/releases/latest' \
|
||||
| sed -E 's#.*/##' \
|
||||
| sed 's/^v//')
|
||||
|
||||
echo "current=$current_version"
|
||||
echo "latest=$latest_version"
|
||||
@@ -110,16 +105,37 @@ jobs:
|
||||
exit 0
|
||||
fi
|
||||
|
||||
curl -fsS -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${api}/pulls" \
|
||||
-d "$(cat <<JSON
|
||||
{
|
||||
\"title\": \"update helium to ${{ steps.update.outputs.version }}\",
|
||||
\"head\": \"${branch}\",
|
||||
\"base\": \"main\",
|
||||
\"body\": \"automated update of helium appimage version and hash\"
|
||||
}
|
||||
JSON
|
||||
)"
|
||||
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 "Content-Type: application/json" \
|
||||
"${api}/pulls" \
|
||||
-d "$(cat <<JSON
|
||||
{
|
||||
"title": "update helium to ${{ steps.update.outputs.version }}",
|
||||
"head": "${head}",
|
||||
"base": "main",
|
||||
"body": "automated update of helium appimage version and hash"
|
||||
}
|
||||
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
|
||||
|
||||
@@ -35,14 +35,10 @@ jobs:
|
||||
PY
|
||||
)
|
||||
|
||||
latest_version=$(python - <<'PY'
|
||||
import json, urllib.request
|
||||
url='https://api.github.com/repos/zen-browser/desktop/releases/latest'
|
||||
with urllib.request.urlopen(url) as r:
|
||||
data=json.load(r)
|
||||
print(data.get('tag_name','').lstrip('v'))
|
||||
PY
|
||||
)
|
||||
latest_version=$(curl -fsSLI -o /dev/null -w '%{url_effective}' \
|
||||
'https://github.com/zen-browser/desktop/releases/latest' \
|
||||
| sed -E 's#.*/##' \
|
||||
| sed 's/^v//')
|
||||
|
||||
echo "current=$current_version"
|
||||
echo "latest=$latest_version"
|
||||
@@ -107,16 +103,37 @@ jobs:
|
||||
exit 0
|
||||
fi
|
||||
|
||||
curl -fsS -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${api}/pulls" \
|
||||
-d "$(cat <<JSON
|
||||
{
|
||||
\"title\": \"update zen browser to ${{ steps.update.outputs.version }}\",
|
||||
\"head\": \"${branch}\",
|
||||
\"base\": \"main\",
|
||||
\"body\": \"automated update of zen browser appimage version and hash\"
|
||||
}
|
||||
JSON
|
||||
)"
|
||||
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 "Content-Type: application/json" \
|
||||
"${api}/pulls" \
|
||||
-d "$(cat <<JSON
|
||||
{
|
||||
"title": "update zen browser to ${{ steps.update.outputs.version }}",
|
||||
"head": "${head}",
|
||||
"base": "main",
|
||||
"body": "automated update of zen browser appimage version and hash"
|
||||
}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user