Skip to content

Commit 33f273d

Browse files
Simplify CLA gate status handling
1 parent d93b381 commit 33f273d

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

.github/workflows/cla-gate.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
name: CLA Gate
22

3-
# This workflow publishes a repository-owned commit status named `CLA Gate`.
4-
# Make `CLA Gate` required instead of requiring CLA Assistant's raw `license/cla`
5-
# status directly. That lets merge queue entries pass without waiting for CLA
6-
# Assistant to report on the synthetic merge-group SHA, while pull requests still
7-
# mirror the real CLA Assistant result.
3+
# This workflow makes CLA checks work with merge queue entries. Merge groups get
4+
# a repository-owned `CLA Gate` commit status on the synthetic queue SHA, while
5+
# pull request/status events use this Actions job result based on CLA Assistant's
6+
# raw `license/cla` status.
87
#
9-
# SECURITY: This workflow uses pull_request_target so it can publish commit
10-
# statuses on external PRs. It must never check out, build, or execute PR code.
8+
# SECURITY: Pull request runs must still check out trusted base-branch code, not
9+
# PR code, before running repository scripts.
1110

1211
on:
13-
pull_request_target:
12+
pull_request:
1413
types: [opened, reopened]
1514
status:
1615
merge_group:
@@ -82,7 +81,7 @@ jobs:
8281
if (context.eventName === "status") {
8382
targetSha = context.payload.sha;
8483
claStatusArgs = ["--sha", targetSha];
85-
} else if (context.eventName === "pull_request_target") {
84+
} else if (context.eventName === "pull_request") {
8685
const pr = context.payload.pull_request;
8786
targetSha = pr.head.sha;
8887
claStatusArgs = ["--pr", String(pr.number)];
@@ -98,9 +97,12 @@ jobs:
9897
return;
9998
}
10099
101-
await postStatus({
102-
sha: targetSha,
103-
state: status.state,
104-
description: status.description || undefined,
105-
targetUrl: status.target_url || undefined,
106-
});
100+
if (status.state === "success") {
101+
core.info(`license/cla is success for ${targetSha}`);
102+
return;
103+
}
104+
105+
const state = status.state || "missing";
106+
const description = status.description || "license/cla status is missing";
107+
const targetUrl = status.target_url ? ` (${status.target_url})` : "";
108+
core.setFailed(`license/cla is ${state}: ${description}${targetUrl}`);

0 commit comments

Comments
 (0)