Repository navigation
feat(negotiation): switch the value format once every node can read it #2631
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CLA | ||
|
Check warning on line 1 in .github/workflows/cla.yml
|
||
| # Two-tier contribution model (see CONTRIBUTING.md): | ||
| # - DCO sign-off is enforced on every PR by the DCO workflow (dco.yml; org members exempt). | ||
| # - A signed Contributor License Agreement (CLA.md) is required ONLY for | ||
| # material/strategic contributions, escalated per-PR by a maintainer applying | ||
| # the `cla-required` label. | ||
| # | ||
| # The authoritative "has a signed CLA on file" state is the CLA registry | ||
| # (signatures/cla.json on the default branch), NOT a label. This job publishes a | ||
| # `legal/cla` commit status that is GREEN by default and turns RED only when | ||
| # `cla-required` is present AND the PR author is not yet in the registry. | ||
| # Mark `legal/cla` as a required status check to enforce it. | ||
| on: | ||
| pull_request_target: | ||
| types: [opened, reopened, synchronize, labeled, unlabeled] | ||
| permissions: | ||
| contents: read | ||
| statuses: write | ||
| pull-requests: write | ||
| jobs: | ||
| cla: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Evaluate CLA status | ||
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | ||
| with: | ||
| script: | | ||
| const pr = context.payload.pull_request; | ||
| const required = pr.labels.map(l => l.name).includes('cla-required'); | ||
| const claUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/main/CLA.md`; | ||
| const registryUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/blob/main/signatures/cla.json`; | ||
| // Read the CLA registry from the BASE branch (trusted) — never the PR head, | ||
| // so a pull request cannot authorize its own author. | ||
| let signed = false; | ||
| try { | ||
| const res = await github.rest.repos.getContent({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| path: 'signatures/cla.json', | ||
| ref: pr.base.ref, | ||
| }); | ||
| const json = JSON.parse(Buffer.from(res.data.content, 'base64').toString('utf8')); | ||
| const users = (json.signatories || []).map(s => String(s.githubUsername || '').toLowerCase()); | ||
| signed = users.includes(String(pr.user.login || '').toLowerCase()); | ||
| } catch (e) { | ||
| if (e.status !== 404) throw e; // missing registry => treat as empty | ||
| } | ||
| const outstanding = required && !signed; | ||
| await github.rest.repos.createCommitStatus({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| sha: pr.head.sha, | ||
| context: 'legal/cla', | ||
| state: outstanding ? 'failure' : 'success', | ||
| description: outstanding | ||
| ? 'Signed CLA required — author not yet in the CLA registry' | ||
| : (required ? 'CLA on file (author in registry)' : 'No CLA required'), | ||
| target_url: outstanding ? claUrl : registryUrl, | ||
| }); | ||
| // Post the instructional comment once, when a CLA first becomes outstanding. | ||
| if (!outstanding) return; | ||
| const marker = '<!-- cla-required-comment -->'; | ||
| const comments = await github.paginate(github.rest.issues.listComments, { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pr.number, | ||
| }); | ||
| if (comments.some(c => c.body && c.body.includes(marker))) return; | ||
| const body = [ | ||
| marker, | ||
| `Thanks for your contribution, @${pr.user.login}! A maintainer flagged this as a **material or strategic** contribution, which requires a signed **Contributor License Agreement (CLA)** in addition to the DCO sign-off.`, | ||
| ``, | ||
| `**What to do:**`, | ||
| `1. Read the [CLA](${claUrl}).`, | ||
| `2. Complete the section that applies to you — **Option A — Individual Contributor** or **Option B — Corporate Contributor** — and sign it.`, | ||
| `3. Email the signed copy to **contractnotice@uipath.com**, referencing this pull request: ${pr.html_url}`, | ||
| ``, | ||
| `Once UiPath records your signed CLA in the [CLA registry](${registryUrl}), the \`legal/cla\` check turns green. The CLA covers your present and future contributions, so this is a one-time step.`, | ||
| ].join('\n'); | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: pr.number, | ||
| body, | ||
| }); | ||