@@ -4,84 +4,3 @@ echo "hi"
44
55set -e
66
7- cat $GITHUB_EVENT_PATH
8-
9- PR_NUMBER=$( jq -r " .issue.number" " $GITHUB_EVENT_PATH " )
10- COMMENT_BODY=$( jq -r " .comment.body" " $GITHUB_EVENT_PATH " )
11-
12- echo $COMMENT_BODY
13-
14- echo " Softfixing #$PR_NUMBER in $GITHUB_REPOSITORY "
15-
16- if [[ -z " $GITHUB_TOKEN " ]]; then
17- echo " Set a github token"
18- exit 1
19- fi
20-
21- URI=" https://api.github.com"
22- ACCEPT_HEADER=" Accept: application/vnd.github.v3+json"
23- AUTH_HEADER=" Authorization: token $GITHUB_TOKEN "
24-
25- pr_response=$( curl -s -H " ${AUTH_HEADER} " -H " ${API_HEADER} " \
26- " ${URI} /repos/$GITHUB_REPOSITORY /pulls/$PR_NUMBER " )
27-
28- BASE_REPO=$( echo " $pr_response " | jq -r .base.repo.full_name)
29- BASE_BRANCH=$( echo " $pr_response " | jq -r .base.ref)
30-
31- USER_LOGIN=$( jq -r " .comment.user.login" " $GITHUB_EVENT_PATH " )
32-
33- user_response=$( curl -s -H " ${AUTH_HEADER} " -H " ${API_HEADER} " \
34- " ${URI} /users/${USER_LOGIN} " )
35-
36- USER_NAME=$( echo " $user_response " | jq -r " .name" )
37- if [[ " $USER_NAME " == " null" ]]; then
38- USER_NAME=$USER_LOGIN
39- fi
40-
41- USER_NAME=" ${USER_NAME} (Softfix Action)"
42-
43- USER_EMAIL=$( echo " $user_response " | jq -r " .email" )
44- if [[ " $USER_EMAIL " == " null" ]]; then
45- USER_EMAIL=" $USER_LOGIN @users.noreply.github.com"
46- fi
47-
48- if [[ -z " $BASE_BRANCH " ]]; then
49- echo " Cannot get base ref information for #$PR_NUMBER "
50- echo " API response: $pr_response "
51- exit 1
52- fi
53-
54- HEAD_REPO=$( echo " $pr_response " | jq -r .head.repo.full_name)
55- HEAD_BRANCH=$( echo " $pr_response " | jq -r .head.ref)
56-
57- echo " Base branch for PR #$PR_NUMBER is $BASE_BRANCH "
58-
59- USER_TOKEN=${USER_LOGIN} _TOKEN
60- COMMITTER_TOKEN=${! USER_TOKEN:- $GITHUB_TOKEN }
61-
62- git remote set-url origin https://x-access-token:$COMMITTER_TOKEN @github.com/$GITHUB_REPOSITORY .git
63- git config --global user.email " $USER_EMAIL "
64- git config --global user.name " $USER_NAME "
65-
66- git remote add fork https://x-access-token:$COMMITTER_TOKEN @github.com/$HEAD_REPO .git
67-
68- set -o xtrace
69-
70- # make sure branches are up-to-date
71- git fetch origin $BASE_BRANCH
72- git fetch fork $HEAD_BRANCH
73-
74- # do the rebase
75- git checkout -b $HEAD_BRANCH fork/$HEAD_BRANCH
76- git reset --soft $BASE_BRANCH
77- git commit -m " sweet"
78-
79- # push back
80- git push --force-with-lease fork $HEAD_BRANCH
81-
82-
83-
84-
85-
86-
87-
0 commit comments