1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# limitations under the License.
14- # Test
1514
1615name : Add Label
1716
4342 } else if (context.payload.workflow_run !== undefined) {
4443 if (context.payload.workflow_run.pull_requests.length === 0) {
4544 console.log("This workflow is NOT running within a PR's context")
46- process.exit()
45+ process.exit(1 )
4746 }
4847 console.log(context.payload.workflow_run.pull_requests)
4948 pull_number = context.payload.workflow_run.pull_requests[0].number
6867
6968 if (reviews.data.length === 0) {
7069 console.log("Not adding pull ready because the PR is not approved yet.")
71- process.exit()
70+ process.exit(1 )
7271 }
7372 let is_approved=false
7473 for (const review of reviews.data) {
7978 }
8079 if (!is_approved) {
8180 console.log("Not adding pull ready because the PR is not approved yet by a code owner.")
82- process.exit()
81+ process.exit(1 )
8382 }
8483
8584 const commits = await github.rest.pulls.listCommits({
9089 })
9190 // Check that the number of commits in the PR is 1.
9291 if (commits.data.length !== 1) {
93- console.log("Not adding pull ready because the PR has more than one commit. Please squash your commits.")
94- process.exit(1)
92+ console.log("The PR has more than one commit. Please squash your commits.")
9593 }
9694 const ref = commits.data.slice(-1)[0].sha
9795 const checkRuns = await github.rest.checks.listForRef({
@@ -101,13 +99,13 @@ jobs:
10199 })
102100 if (checkRuns.data.check_runs.length === 0) {
103101 console.log("Not adding pull ready because no check runs are associated with the last commit: " + ref)
104- process.exit()
102+ process.exit(1 )
105103 }
106104 for (const checkRun of checkRuns.data.check_runs) {
107105 if (checkRun.name.endsWith(context.job)) continue
108106 if (checkRun.conclusion !== "success") {
109107 console.log("Not adding pull ready because " + checkRun.name + " has not passed yet: " + checkRun.html_url)
110- process.exit()
108+ process.exit(1 )
111109 }
112110 }
113111 console.log("Adding pull ready label because the PR is approved AND all the check runs have passed")
0 commit comments