@@ -37,6 +37,18 @@ gitHubCurl() {
37
37
--header ' content-type: application/json' " $@ "
38
38
}
39
39
40
+ commit_queue_failed () {
41
+ gitHubCurl " $( labelsUrl " ${1} " ) " POST --data ' {"labels": ["' " ${COMMIT_QUEUE_FAILED_LABEL} " ' "]}'
42
+
43
+ # shellcheck disable=SC2154
44
+ cqurl=" ${GITHUB_SERVER_URL} /${OWNER} /${REPOSITORY} /actions/runs/${GITHUB_RUN_ID} "
45
+ jq -n --arg content " <details><summary>Commit Queue failed</summary><pre>$( cat output) </pre><a href='$cqurl '>$cqurl </a></details>" ' {body: $content}' > output.json
46
+ cat output.json
47
+
48
+ gitHubCurl " $( commentsUrl " ${1} " ) " POST --data @output.json
49
+
50
+ rm output output.json
51
+ }
40
52
41
53
# TODO(mmarchini): should this be set with whoever added the label for each PR?
42
54
git config --local user.email
" [email protected] "
@@ -64,30 +76,25 @@ for pr in "$@"; do
64
76
65
77
# TODO(mmarchini): workaround for ncu not returning the expected status code,
66
78
# if the "Landed in..." message was not on the output we assume land failed
67
- if ! tail -n 10 output | grep ' . Post "Landed in .*/pull/' " ${pr} " ; then
68
- gitHubCurl " $( labelsUrl " $pr " ) " POST --data ' {"labels": ["' " ${COMMIT_QUEUE_FAILED_LABEL} " ' "]}'
69
-
70
- # shellcheck disable=SC2154
71
- cqurl=" ${GITHUB_SERVER_URL} /${OWNER} /${REPOSITORY} /actions/runs/${GITHUB_RUN_ID} "
72
- jq -n --arg content " <details><summary>Commit Queue failed</summary><pre>$( cat output) </pre><a href='$cqurl '>$cqurl </a></details>" ' {body: $content}' > output.json
73
- cat output.json
74
-
75
- gitHubCurl " $( commentsUrl " $pr " ) " POST --data @output.json
76
-
77
- rm output output.json
79
+ if ! grep -q ' . Post "Landed in .*/pull/' " ${pr} " output; then
80
+ commit_queue_failed " $pr "
78
81
# If `git node land --abort` fails, we're in unknown state. Better to stop
79
82
# the script here, current PR was removed from the queue so it shouldn't
80
83
# interfere again in the future.
81
84
git node land --abort --yes
82
- else
83
- rm output
85
+ continue
86
+ fi
87
+
88
+ commits=" $( git rev-parse $UPSTREAM /$DEFAULT_BRANCH ) ...$( git rev-parse HEAD) "
84
89
85
- commits=" $( git rev-parse $UPSTREAM /$DEFAULT_BRANCH ) ...$( git rev-parse HEAD) "
90
+ if ! git push $UPSTREAM $DEFAULT_BRANCH >> output 2>&1 ; then
91
+ commit_queue_failed " $pr "
92
+ continue
93
+ fi
86
94
87
- git push $UPSTREAM $DEFAULT_BRANCH
95
+ rm output
88
96
89
- gitHubCurl " $( commentsUrl " $pr " ) " POST --data ' {"body": "Landed in ' " $commits " ' "}'
97
+ gitHubCurl " $( commentsUrl " $pr " ) " POST --data ' {"body": "Landed in ' " $commits " ' "}'
90
98
91
- gitHubCurl " $( issueUrl " $pr " ) " PATCH --data ' {"state": "closed"}'
92
- fi
99
+ gitHubCurl " $( issueUrl " $pr " ) " PATCH --data ' {"state": "closed"}'
93
100
done
0 commit comments