Skip to content

Commit d2d6d95

Browse files
authored
Merge pull request espressif#299 from lucasssvaz/fix/deploy_check
fix(deploy): Increase page limit and add pagination to releases
2 parents d7bdda2 + 1a35d2d commit d2d6d95

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

tools/config.sh

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function github_get_libs_idf(){ # github_get_libs_idf <repo-path> <branch-name>
108108
local version_found=""
109109
local libs_version=""
110110

111-
while [[ "$libs_version" == "" && "$page" -le 3 ]]; do
111+
while [[ "$libs_version" == "" && "$page" -le 5 ]]; do
112112
# Get the latest commit message that matches the prefix and extract the hash from the last commit message
113113
version_found=`curl -s -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/commits?sha=$branch_name&per_page=100&page=$page" | \
114114
jq -r --arg prefix "$message_prefix" '[ .[] | select(.commit.message | test($prefix + " [a-f0-9]{8}")) ][0] | .commit.message' | \
@@ -131,7 +131,7 @@ function github_commit_exists(){ #github_commit_exists <repo-path> <branch-name>
131131
local page=1
132132
local commits_found=0
133133

134-
while [ "$page" -le 3 ]; do
134+
while [ "$page" -le 5 ]; do
135135
local response=`curl -s -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/commits?sha=$branch_name&per_page=100&page=$page"`
136136

137137
if [[ -z "$response" || "$response" == "[]" ]]; then
@@ -178,16 +178,52 @@ function github_pr_exists(){ # github_pr_exists <repo-path> <branch-name>
178178
function github_release_id(){ # github_release_id <repo-path> <release-tag>
179179
local repo_path="$1"
180180
local release_tag="$2"
181-
local release=`curl -s -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/releases" | jq --arg release_tag "$release_tag" -r '.[] | select(.tag_name == $release_tag) | .id'`
182-
if [ ! "$release" == "" ] && [ ! "$release" == "null" ]; then echo "$release"; else echo ""; fi
181+
local page=1
182+
local release_id=""
183+
184+
while [[ "$page" -le 3 ]]; do
185+
local response=`curl -s -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/releases?per_page=100&page=$page"`
186+
187+
if [[ -z "$response" || "$response" == "[]" ]]; then
188+
break
189+
fi
190+
191+
local release=`echo "$response" | jq --arg release_tag "$release_tag" -r '.[] | select(.tag_name == $release_tag) | .id'`
192+
if [ ! "$release" == "" ] && [ ! "$release" == "null" ]; then
193+
release_id=$release
194+
break
195+
fi
196+
197+
page=$((page+1))
198+
done
199+
200+
echo "$release_id"
183201
}
184202

185203
function github_release_asset_id(){ # github_release_asset_id <repo-path> <release-id> <release-file>
186204
local repo_path="$1"
187205
local release_id="$2"
188206
local release_file="$3"
189-
local release_asset=`curl -s -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/releases/$release_id/assets" | jq --arg release_file "$release_file" -r '.[] | select(.name == $release_file) | .id'`
190-
if [ ! "$release_asset" == "" ] && [ ! "$release_asset" == "null" ]; then echo "$release_asset"; else echo ""; fi
207+
local page=1
208+
local asset_id=""
209+
210+
while [[ "$page" -le 5 ]]; do
211+
local response=`curl -s -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/releases/$release_id/assets?per_page=100&page=$page"`
212+
213+
if [[ -z "$response" || "$response" == "[]" ]]; then
214+
break
215+
fi
216+
217+
local release_asset=`echo "$response" | jq --arg release_file "$release_file" -r '.[] | select(.name == $release_file) | .id'`
218+
if [ ! "$release_asset" == "" ] && [ ! "$release_asset" == "null" ]; then
219+
asset_id=$release_asset
220+
break
221+
fi
222+
223+
page=$((page+1))
224+
done
225+
226+
echo "$asset_id"
191227
}
192228

193229
function github_release_asset_upload(){ # github_release_asset_upload <repo-path> <release-id> <release-file-name> <release-file-path>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy