|
1 | 1 | name: CLA Gate |
2 | 2 |
|
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. |
8 | 7 | # |
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. |
11 | 10 |
|
12 | 11 | on: |
13 | | - pull_request_target: |
| 12 | + pull_request: |
14 | 13 | types: [opened, reopened] |
15 | 14 | status: |
16 | 15 | merge_group: |
|
82 | 81 | if (context.eventName === "status") { |
83 | 82 | targetSha = context.payload.sha; |
84 | 83 | claStatusArgs = ["--sha", targetSha]; |
85 | | - } else if (context.eventName === "pull_request_target") { |
| 84 | + } else if (context.eventName === "pull_request") { |
86 | 85 | const pr = context.payload.pull_request; |
87 | 86 | targetSha = pr.head.sha; |
88 | 87 | claStatusArgs = ["--pr", String(pr.number)]; |
|
98 | 97 | return; |
99 | 98 | } |
100 | 99 |
|
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