Skip to content

Commit bdd34ac

Browse files
committed
ci(deploy): Fix deploy output
1 parent 6b0a0e6 commit bdd34ac

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

.github/workflows/cron.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defaults:
2121
jobs:
2222
build-libs:
2323
name: Build with IDF ${{ matrix.idf_branch }}
24-
if: github.repository_owner == 'espressif'
24+
if: github.repository_owner == 'espressif' || github.event_name == 'workflow_dispatch'
2525
uses: ./.github/workflows/cron_build.yml
2626
with:
2727
idf_branch: ${{ matrix.idf_branch }}

.github/workflows/cron_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
env:
5252
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5353
run: |
54-
source ./tools/check-deploy-needed.sh
54+
bash ./tools/check-deploy-needed.sh
5555
targets_list=$(echo "${{ inputs.targets }}" | sed 's/ *, */,/g' | sed 's/^/["/' | sed 's/$/"]/' | sed 's/,/","/g')
5656
echo "Targets list: $targets_list"
5757
echo "targets_list=$targets_list" >> $GITHUB_OUTPUT

tools/check-deploy-needed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ echo "LIBS_ASSET_ID: $LIBS_ASSET_ID"
119119
echo "LIBS_HAS_ASSET: $LIBS_HAS_ASSET"
120120
echo "DEPLOY_NEEDED: $DEPLOY_NEEDED"
121121

122-
if [ ! -x $GITHUB_OUTPUT ]; then
122+
if [ -n "$GITHUB_OUTPUT" ]; then
123123
echo "idf_commit=$IDF_COMMIT" >> "$GITHUB_OUTPUT"
124124
echo "ar_branch=$AR_BRANCH" >> "$GITHUB_OUTPUT"
125125
echo "ar_new_commit_message=$AR_NEW_COMMIT_MESSAGE" >> "$GITHUB_OUTPUT"

tools/config.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,29 +175,35 @@ function github_pr_exists(){ # github_pr_exists <repo-path> <branch-name>
175175
if [ ! "$pr_num" == "" ] && [ ! "$pr_num" == "null" ]; then echo 1; else echo 0; fi
176176
}
177177

178-
function github_release_id(){ # github_release_id <repo-path> <release-tag>
178+
function github_release_id() { # github_release_id <repo-path> <release-tag>
179179
local repo_path="$1"
180180
local release_tag="$2"
181181
local page=1
182182
local release_id=""
183183

184184
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
185+
local response
186+
response=$(curl -sf -H "Authorization: token $GITHUB_TOKEN" \
187+
-H "Accept: application/vnd.github.v3.raw+json" \
188+
"https://api.github.com/repos/$repo_path/releases?per_page=100&page=$page") || {
189+
echo "Failed to fetch releases from GitHub for $repo_path" >&2
190+
exit 1
191+
}
192+
193+
# stop if empty or no releases
194+
[[ -z "$response" || "$response" == "[]" ]] && break
195+
196+
release_id=$(echo "$response" | jq --arg tag "$release_tag" -r '.[] | select(.tag_name == $tag) | .id')
197+
if [[ -n "$release_id" && "$release_id" != "null" ]]; then
198+
echo "$release_id"
199+
return 0
195200
fi
196201

197202
page=$((page+1))
198203
done
199204

200-
echo "$release_id"
205+
echo "Release '$release_tag' not found in $repo_path" >&2
206+
exit 1
201207
}
202208

203209
function github_release_asset_id(){ # github_release_asset_id <repo-path> <release-id> <release-file>

0 commit comments

Comments
 (0)