diff --git a/.github/workflows/cla-trigger.yml b/.github/workflows/cla-trigger.yml new file mode 100644 index 0000000..3c1faec --- /dev/null +++ b/.github/workflows/cla-trigger.yml @@ -0,0 +1,18 @@ +name: CLA trigger + +on: + pull_request: + types: [opened, reopened, synchronize] + +permissions: {} + +jobs: + # Its completion starts the CLA workflow, which checks the pull request with the signature App. + # Not named `cla`, since a check with that name would satisfy the required `cla` status, except + # on Dependabot's own runs: the CLA workflow skips those, and its PRs need no signature. + trigger: + name: ${{ github.actor == 'dependabot[bot]' && 'cla' || 'trigger' }} + runs-on: ubuntu-24.04 + timeout-minutes: 1 + steps: + - run: echo "The CLA workflow checks this pull request when this run completes." diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 2d4acb3..31078b2 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -1,28 +1,29 @@ name: CLA on: + workflow_run: + workflows: [CLA trigger] + types: [completed] issue_comment: types: [created] - pull_request_target: - types: [opened, reopened, synchronize] permissions: {} jobs: - cla: - # Dependabot-triggered runs cannot access the App secret; human updates and rechecks still run. + # Reports a `cla` commit status on the pull request's head; this job's own check lands on main. + check: if: | - github.actor != 'dependabot[bot]' && - (github.event_name == 'pull_request_target' || - (github.event_name == 'issue_comment' && github.event.issue.pull_request && - github.event.comment.user.type != 'Bot' && - (contains(github.event.comment.body, 'CLA') || contains(github.event.comment.body, 'recheck')))) + (github.event_name == 'workflow_run' && github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.actor.login != 'dependabot[bot]') || + (github.event_name == 'issue_comment' && github.event.issue.pull_request && + github.event.comment.user.type != 'Bot' && + (contains(github.event.comment.body, 'CLA') || contains(github.event.comment.body, 'recheck'))) runs-on: ubuntu-24.04 timeout-minutes: 5 permissions: - actions: write contents: read pull-requests: write + statuses: write steps: # This privileged workflow must never check out or execute pull-request code. - name: Create signature writer token @@ -34,11 +35,14 @@ jobs: owner: ${{ github.repository_owner }} repositories: ${{ github.event.repository.name }} permission-single-file: write - - uses: openwatersio/cla-github-action@599be7e585704b7eb53be7498aebefc0e7d8caac # Open Waters fork + - uses: openwatersio/cla-github-action@f07dfd38224fde9ace8e7b8437ba318e0db042ea # Open Waters fork env: GITHUB_TOKEN: ${{ github.token }} PERSONAL_ACCESS_TOKEN: ${{ steps.cla-token.outputs.token }} with: + # The open pull request whose head is this commit is checked; nothing from the triggering run is trusted. + head-sha: ${{ github.event.workflow_run.head_sha }} + status-context: cla path-to-document: "https://github.com/${{ github.repository }}/blob/main/CLA.md" path-to-signatures: ".cla.json" branch: "main" diff --git a/docs/licensing.md b/docs/licensing.md index c52b09a..94032ab 100644 --- a/docs/licensing.md +++ b/docs/licensing.md @@ -39,9 +39,9 @@ Signal (AGPLv3) uses this exact approach to distribute on the iOS App Store. The The CLA workflow records signatures in `.cla.json` on `main` using the organization-owned Open Waters CLA App. The App has Single file write permission for `.cla.json` and Metadata read permission. It needs a bypass in any ruleset that would reject its signature commits; the ordinary GitHub Actions token does not need a bypass. -Maintainers configure the organization variable `CLA_APP_CLIENT_ID` and encrypted Actions secret `CLA_APP_PRIVATE_KEY`, restricted to the participating repositories. The workflow creates a short-lived token scoped to this repository. Never check out or execute pull-request code in this privileged workflow. See the [shared setup guide](https://github.com/openwatersio/cla-github-action/blob/master/docs/open-waters.md). +Maintainers configure the organization variable `CLA_APP_CLIENT_ID` and encrypted Actions secret `CLA_APP_PRIVATE_KEY`, restricted to the participating repositories. The workflow creates a short-lived token scoped to this repository. Never check out or execute pull-request code in the privileged CLA workflow. See the [shared setup guide](https://github.com/openwatersio/cla-github-action/blob/master/docs/open-waters.md). -Human comments mentioning the CLA or `recheck` reach the action's signing-text validation. Dependabot-initiated runs are skipped because Actions secrets are unavailable; human updates and recheck comments still run. Claude co-author metadata is exempt, while human contributors must sign. If storage rejects a write, the check fails; comment `recheck` to retry. The workflow result and `.cla.json` are authoritative even if a bot comment has already acknowledged signing. +Each pull request runs the secret-free `CLA trigger` workflow. When it completes, the CLA workflow runs from `main`, checks the open pull request whose head is that commit, and sets a `cla` commit status on it. Human comments mentioning the CLA or `recheck` reach the action's signing-text validation and update the status. Claude co-author metadata is exempt, while human contributors must sign. If storage rejects a write, the `cla` status reports an error; comment `recheck` to retry. The `cla` status and `.cla.json` are authoritative even if a bot comment has already acknowledged signing. An unsigned result shows only in the status, not as a failed CLA workflow run. ## References