11name : CLA Gate
22
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.
7- #
8- # SECURITY: Pull request runs must still check out trusted base-branch code, not
9- # PR code, before running repository scripts.
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.
108
119on :
1210 pull_request :
@@ -42,11 +40,20 @@ jobs:
4240 const { execFileSync } = require("child_process");
4341
4442 function claStatus(args) {
45- const output = execFileSync("cargo", ["ci", "cla-assistant", "status", ...args], {
43+ const command = ["ci", "cla-assistant", "status", ...args];
44+ core.info(`Running cargo ${command.join(" ")}`);
45+ const output = execFileSync("cargo", command, {
4646 encoding: "utf8",
4747 env: process.env,
4848 });
49- return JSON.parse(output);
49+ core.info(`cargo ci output: ${output.trim()}`);
50+ const status = JSON.parse(output);
51+ core.info(
52+ `Resolved license/cla for ${status.sha}: state=${status.state || "missing"} ` +
53+ `description=${status.description || "<none>"} ` +
54+ `target_url=${status.target_url || "<none>"}`
55+ );
56+ return status;
5057 }
5158
5259 async function postStatus({ sha, state, description, targetUrl }) {
6976 let targetSha;
7077 let claStatusArgs;
7178
79+ core.info(
80+ `Handling ${context.eventName} event for workflow SHA ${process.env.GITHUB_SHA}`
81+ );
82+
7283 if (context.eventName === "merge_group") {
84+ core.info(`Merge group SHA is ${process.env.GITHUB_SHA}`);
7385 await postStatus({
7486 sha: process.env.GITHUB_SHA,
7587 state: "success",
@@ -81,28 +93,30 @@ jobs:
8193 if (context.eventName === "status") {
8294 targetSha = context.payload.sha;
8395 claStatusArgs = ["--sha", targetSha];
96+ core.info(
97+ `status event context=${context.payload.context} state=${context.payload.state} sha=${targetSha}`
98+ );
8499 } else if (context.eventName === "pull_request") {
85100 const pr = context.payload.pull_request;
86101 targetSha = pr.head.sha;
87102 claStatusArgs = ["--pr", String(pr.number)];
103+ core.info(`pull_request event PR #${pr.number} head SHA is ${targetSha}`);
88104 } else {
89105 core.setFailed(`Unsupported event type: ${context.eventName}`);
90106 return;
91107 }
92108
109+ core.info(`Checking license/cla with args: ${claStatusArgs.join(" ")}`);
93110 const status = claStatus(claStatusArgs);
94111
95112 if (!status.state) {
96113 core.info(`No CLA Gate status to publish for ${targetSha}`);
97114 return;
98115 }
99116
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}`);
117+ await postStatus({
118+ sha: targetSha,
119+ state: status.state,
120+ description: status.description || undefined,
121+ targetUrl: status.target_url || undefined,
122+ });
0 commit comments