Skip to content

Commit 6073bf8

Browse files
committed
test
1 parent a32cf3e commit 6073bf8

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

.github/workflows/cron_build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
ar_new_pr_title: ${{ steps.check.outputs.ar_new_pr_title }}
3232
ar_has_commit: ${{ steps.check.outputs.ar_has_commit }}
3333
ar_has_branch: ${{ steps.check.outputs.ar_has_branch }}
34+
ar_pr_number: ${{ steps.check.outputs.ar_pr_number }}
3435
ar_has_pr: ${{ steps.check.outputs.ar_has_pr }}
3536
libs_release_tag: ${{ steps.check.outputs.libs_release_tag }}
3637
libs_version: ${{ steps.check.outputs.libs_version }}
@@ -144,6 +145,7 @@ jobs:
144145
AR_NEW_PR_TITLE: ${{ needs.check-if-needed.outputs.ar_new_pr_title }}
145146
AR_HAS_COMMIT: ${{ needs.check-if-needed.outputs.ar_has_commit }}
146147
AR_HAS_BRANCH: ${{ needs.check-if-needed.outputs.ar_has_branch }}
148+
AR_PR_NUMBER: ${{ needs.check-if-needed.outputs.ar_pr_number }}
147149
AR_HAS_PR: ${{ needs.check-if-needed.outputs.ar_has_pr }}
148150
LIBS_RELEASE_TAG: ${{ needs.check-if-needed.outputs.libs_release_tag }}
149151
LIBS_VERSION: ${{ needs.check-if-needed.outputs.libs_version }}

tools/check-deploy-needed.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ if [ "$AR_HAS_BRANCH" == "1" ]; then
4545
else
4646
AR_HAS_COMMIT=`github_commit_exists "$AR_REPO" "$AR_BRANCH" "$IDF_COMMIT"`
4747
fi
48-
AR_HAS_PR=`github_pr_exists "$AR_REPO" "$AR_NEW_BRANCH_NAME"`
48+
49+
AR_PR_NUMBER=`github_pr_number "$AR_REPO" "$AR_NEW_BRANCH_NAME"`
50+
AR_HAS_PR=`if [ -n "$AR_PR_NUMBER" ]; then echo "1"; else echo "0"; fi`
4951

5052
LIBS_RELEASE_ID=`github_release_id "$AR_LIBS_REPO" "$LIBS_RELEASE_TAG"`
5153
LIBS_HAS_RELEASE=`if [ -n "$LIBS_RELEASE_ID" ]; then echo "1"; else echo "0"; fi`
@@ -60,6 +62,7 @@ export AR_NEW_PR_TITLE
6062

6163
export AR_HAS_COMMIT
6264
export AR_HAS_BRANCH
65+
export AR_PR_NUMBER
6366
export AR_HAS_PR
6467

6568
export LIBS_RELEASE_TAG
@@ -89,6 +92,7 @@ echo "AR_NEW_BRANCH_NAME: $AR_NEW_BRANCH_NAME"
8992
echo "AR_NEW_PR_TITLE: $AR_NEW_PR_TITLE"
9093
echo "AR_HAS_COMMIT: $AR_HAS_COMMIT"
9194
echo "AR_HAS_BRANCH: $AR_HAS_BRANCH"
95+
echo "AR_PR_NUMBER: $AR_PR_NUMBER"
9296
echo "AR_HAS_PR: $AR_HAS_PR"
9397
echo "LIBS_RELEASE_TAG: $LIBS_RELEASE_TAG"
9498
echo "LIBS_VERSION: $LIBS_VERSION"
@@ -106,6 +110,7 @@ if [ ! -x $GITHUB_OUTPUT ]; then
106110
echo "ar_new_pr_title=$AR_NEW_PR_TITLE" >> "$GITHUB_OUTPUT"
107111
echo "ar_has_commit=$AR_HAS_COMMIT" >> "$GITHUB_OUTPUT"
108112
echo "ar_has_branch=$AR_HAS_BRANCH" >> "$GITHUB_OUTPUT"
113+
echo "ar_pr_number=$AR_PR_NUMBER" >> "$GITHUB_OUTPUT"
109114
echo "ar_has_pr=$AR_HAS_PR" >> "$GITHUB_OUTPUT"
110115
echo "libs_release_tag=$LIBS_RELEASE_TAG" >> "$GITHUB_OUTPUT"
111116
echo "libs_version=$LIBS_VERSION" >> "$GITHUB_OUTPUT"

tools/combine-artifacts.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ done
1616
awk -i inplace '!seen[$0]++' $libs_folder/versions_full.txt
1717
mv -f $libs_folder/versions_full.txt $libs_folder/versions.txt
1818

19-
cd out/tools && zip -X -q -r ../../dist/esp32-arduino-libs.zip * && cd ../..
19+
echo "Creating zip file"
20+
cd out/tools && zip -X -D -q -r ../../dist/esp32-arduino-libs.zip * && cd ../..

tools/config.sh

+13-3
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ function github_branch_exists(){ # github_branch_exists <repo-path> <branch-name
124124
if [ "$branch" == "$branch_name" ]; then echo 1; else echo 0; fi
125125
}
126126

127-
function github_pr_exists(){ # github_pr_exists <repo-path> <branch-name>
127+
function github_pr_number(){ # github_pr_number <repo-path> <branch-name>
128128
local repo_path="$1"
129129
local branch_name="$2"
130130
local pr_num=`curl -s -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/pulls?head=$AR_USER:$branch_name&state=open" | jq -r '.[].number'`
131-
if [ ! "$pr_num" == "" ] && [ ! "$pr_num" == "null" ]; then echo 1; else echo 0; fi
131+
if [ ! "$pr_num" == "" ] && [ ! "$pr_num" == "null" ]; then echo "$pr_num"; else echo ""; fi
132132
}
133133

134134
function github_release_id(){ # github_release_id <repo-path> <release-tag>
@@ -178,7 +178,7 @@ function git_commit_exists(){ #git_commit_exists <repo-path> <commit-message>
178178
if [ -n "$commits_found" ]; then echo 1; else echo 0; fi
179179
}
180180

181-
function git_create_pr(){ # git_create_pr <branch> <title>
181+
function git_create_pr(){ # git_create_pr <branch> <title> <target>
182182
local pr_branch="$1"
183183
local pr_title="$2"
184184
local pr_target="$3"
@@ -191,3 +191,13 @@ function git_create_pr(){ # git_create_pr <branch> <title>
191191
if [ ! "$done_pr" == "" ] && [ ! "$done_pr" == "null" ]; then echo 1; else echo 0; fi
192192
}
193193

194+
function git_update_pr(){ # git_update_pr <number>
195+
local pr_number="$1"
196+
local pr_body="\`\`\`\r\n"
197+
while read -r line; do pr_body+=$line"\r\n"; done < "$AR_TOOLS/esp32-arduino-libs/versions.txt"
198+
pr_body+="\`\`\`\r\n"
199+
local pr_data="{\"body\": \"$pr_body\"}"
200+
git_update_pr_res=`echo "$pr_data" | curl -k -X PATCH -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" --data @- "https://api.github.com/repos/$AR_REPO/pulls/$pr_number"`
201+
local done_pr=`echo "$git_update_pr_res" | jq -r '.title'`
202+
if [ ! "$done_pr" == "" ] && [ ! "$done_pr" == "null" ]; then echo 1; else echo 0; fi
203+
}

tools/push-to-arduino.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fi
117117
# esp32-arduino
118118
#
119119

120-
if [ $AR_HAS_COMMIT == "0" ]; then
120+
if [ $AR_HAS_COMMIT == "0" ] || [ $LIBS_HAS_ASSET == "0" ]; then
121121
cd "$AR_ROOT"
122122
# create or checkout the branch
123123
if [ ! $AR_HAS_BRANCH == "0" ]; then
@@ -164,7 +164,12 @@ if [ $AR_HAS_COMMIT == "0" ]; then
164164
exit 1
165165
fi
166166
else
167-
echo "PR '$AR_NEW_PR_TITLE' Already Exists"
167+
echo "Updating PR $AR_PR_NUMBER..."
168+
pr_updated=`git_update_pr "$AR_PR_NUMBER"`
169+
if [ $pr_updated == "0" ]; then
170+
echo "ERROR: Failed to update PR '$AR_NEW_PR_TITLE': "`echo "$git_update_pr_res" | jq -r '.message'`": "`echo "$git_update_pr_res" | jq -r '.errors[].message'`
171+
exit 1
172+
fi
168173
fi
169174
fi
170175

0 commit comments

Comments
 (0)