Skip to content

Commit 9ce578d

Browse files
msyycBigCat20196
andauthored
[pipeline] add variable for paste issue_link (Azure#20128)
* Update create_auto_release_pr * Update create_auto_release_pr.py * Update create_auto_release_pr.py * Update create_auto_release_pr.py * Update create_auto_release_pr.py * Update create_auto_release_pr.py * Update PythonSdkLiveTest.yml Co-authored-by: BigCat20196 <[email protected]> Co-authored-by: Jiefeng Chen <[email protected]>
1 parent 7f483db commit 9ce578d

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

scripts/auto_release/PythonSdkLiveTest.yml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ jobs:
2323
addToPath: true
2424
architecture: 'x64'
2525
- bash: |
26-
# verify $ISSUE_LINK and $BASE_BRANCH is not null
26+
# verify $ISSUE_LINK and $BASE_BRANCH are not null
2727
if [ -z "$(BASE_BRANCH)" -o -z "$(ISSUE_LINK)" ]; then
2828
echo "ISSUE_LINK or BASE_BRANCH do not exist, pipeline fail!!!"
2929
exit 1
3030
fi
31-
31+
3232
script_path=$(pwd)/scripts/auto_release
3333
cd ..
3434
git config --global user.email "PythonSdkPipelines"
@@ -66,28 +66,24 @@ jobs:
6666
exit 1
6767
fi
6868
69-
test_result=""
69+
test_result="Live test success"
7070
if [ -f "$output_path/live_test_fail.txt" ]; then
7171
test_result="Live test fail, detailed info is in pipeline log(search keyword FAILED)!!!\n"
7272
fi
7373
7474
# create PR
75-
new_branch=`sed -n '1p' $output_path/output.txt`
76-
target_branch=`sed -n '2p' $output_path/output.txt`
77-
curl \
78-
--user "anything:$(USR_TOKEN)" \
79-
-d "{\
80-
\"title\":\"[AutoRelease] $new_branch(Do not merge)\",\
81-
\"body\":\"$test_result $(ISSUE_LINK) \",\
82-
\"head\":\"$(USR_NAME):$new_branch\",\
83-
\"base\":\"$target_branch\"\
84-
}" \
85-
https://api.github.com/repos/Azure/azure-sdk-for-python/pulls
75+
export NEW_BRANCH=`sed -n '1p' $output_path/output.txt`
76+
export TARGET_BRANCH=`sed -n '2p' $output_path/output.txt`
77+
export ISSUE_LINK=$(ISSUE_LINK)
78+
export USR_NAME=$(USR_NAME)
79+
export USR_TOKEN=$(USR_TOKEN)
80+
export TEST_RESULT=$test_result
8681
82+
python $script_path/create_auto_release_pr.py
8783
echo "\'[AutoRelease] $new_branch \' has been created!!!"
8884
8985
# if test fail, still push and crete PR. But pipeline would fail to remind user
9086
if [ -f "$output_path/live_test_fail.txt" ]; then
91-
echo "please fix failure test!!! $(ISSUE_LINK) \'[AutoRelease] $new_branch \' has been created!!!"
87+
echo "please fix failure test $(ISSUE_LINK)!!! \'[AutoRelease] $new_branch \' has been created!!!"
9288
exit 1
9389
fi
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
3+
from ghapi.all import GhApi
4+
5+
def main():
6+
# Generate PR for auto release SDK
7+
api = GhApi(owner='Azure', repo='azure-sdk-for-python', token=os.getenv('USR_TOKEN'))
8+
pr_title = "[AutoRelease] {}(Do not merge)".format(os.getenv('NEW_BRANCH'))
9+
pr_head = "{}:{}".format(os.getenv('USR_NAME'), os.getenv('NEW_BRANCH'))
10+
pr_base = os.getenv('TARGET_BRANCH')
11+
pr_body = "{} \n{}".format(os.getenv('ISSUE_LINK'), os.getenv('TEST_RESULT'))
12+
api.pulls.create(pr_title, pr_head, pr_base, pr_body)
13+
14+
if __name__ == '__main__':
15+
main()
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
azure-identity
2-
python-dotenv==0.15.0
2+
python-dotenv==0.15.0
3+
ghapi

0 commit comments

Comments
 (0)