-
Notifications
You must be signed in to change notification settings - Fork 73
ci: implement ruleset-first safe PR Gate #880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mattbodle
wants to merge
13
commits into
mParticle:main
Choose a base branch
from
mattbodle:ci/rokt-safe-pr-gate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
72bbcb1
ci: add Rokt safe PR approval gate
mattbodle 653970a
fix: handle Gate API pagination and fork PR runs
mattbodle ffed9db
refactor(ci): use ruleset-first safe PR gate
mattbodle 5bda625
fix(ci): harden safe PR Gate decisions
mattbodle 1b88e4f
fix(ci): address safe PR Gate review feedback
mattbodle e47f234
Merge branch 'main' into ci/rokt-safe-pr-gate
mattbodle 72fdf8b
Merge branch 'main' into ci/rokt-safe-pr-gate
mattbodle d1bf2bf
fix(ci): serialize safe PR Gate evaluations
mattbodle fd15d62
fix(ci): complete current safe PR Gate checks
mattbodle 18ad493
fix(ci): claim safe PR Gate evaluations
mattbodle ec85a41
Merge branch 'main' into ci/rokt-safe-pr-gate
mattbodle 34be4a8
fix: address safe PR Gate review feedback
mattbodle bbc7865
Merge branch 'main' into ci/rokt-safe-pr-gate
mattbodle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Rokt Safe PR Gate Setup | ||
|
|
||
| The gate is inert until the administrator setup below is complete. Do not add its | ||
| status check to the `main` ruleset until the proof of concept passes. | ||
|
|
||
| ## 1. Create and install the App | ||
|
|
||
| Create one GitHub App and install it in both organisations. | ||
|
|
||
| | Installation | Required permissions | | ||
| | ------------ | ----------------------------------------------------------------- | | ||
| | `mParticle` | Actions: read; Checks: write; Contents: read; Pull requests: read | | ||
| | `ROKT` | Members: read | | ||
|
|
||
| The App must not receive contents-write, administration, merge, push, or ruleset-bypass | ||
| permissions. | ||
|
|
||
| ## 2. Create the code-owner reviewer | ||
|
|
||
| Create a dedicated machine user and add it to the existing `@mParticle/sdk-team` team. | ||
| This is necessary because the active `main` ruleset requires a Code Owner approval, and | ||
| GitHub Apps cannot be listed as Code Owners. Limit its token to this repository and pull | ||
| request review access. | ||
|
|
||
| ## 3. Configure repository settings | ||
|
|
||
| Add these repository variables: | ||
|
|
||
| | Variable | Value | | ||
| | -------------------------------------- | ---------------------------------------- | | ||
| | `ROKT_SAFE_PR_GATE_ENABLED` | `true` after validation | | ||
| | `ROKT_SAFE_PR_GATE_APP_ID` | Numeric GitHub App ID | | ||
| | `ROKT_SAFE_PR_GATE_EMPLOYEE_TEAM_SLUG` | IdP-synchronised Rokt employee team slug | | ||
| | `ROKT_SAFE_PR_GATE_REVIEWER_LOGIN` | Machine-user GitHub login | | ||
|
|
||
| Add these repository secrets: | ||
|
|
||
| | Secret | Value | | ||
| | ----------------------------------- | ------------------------------- | | ||
| | `ROKT_SAFE_PR_GATE_APP_PRIVATE_KEY` | GitHub App private key | | ||
| | `ROKT_SAFE_PR_GATE_REVIEWER_TOKEN` | Machine-user fine-grained token | | ||
|
|
||
| ## 4. Validate before enforcement | ||
|
|
||
| Test an employee documentation-only PR, a non-employee documentation PR, a mixed | ||
| documentation-and-source PR, and a workflow-file change. Confirm that each decision is | ||
| made for the newest PR SHA and that a push dismisses the previous automated approval. | ||
|
|
||
| ## 5. Enable the ruleset check | ||
|
|
||
| Edit the active `main` ruleset and add `Rokt Safe PR Gate` as a required, strict status | ||
| check. Pin the expected source to the new GitHub App. Retain the existing Code Owner | ||
| requirement, one required approval, stale-review dismissal, and resolved-thread rule. | ||
|
|
||
| ## Rollback | ||
|
|
||
| Set `ROKT_SAFE_PR_GATE_ENABLED` to `false`, then remove the Gate status check from the | ||
| ruleset. The repository returns to its existing manual Code Owner review behaviour. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Rokt Safe PR Gate | ||
| description: Evaluates and approves eligible low-risk pull requests. | ||
| inputs: | ||
| api-url: | ||
| required: true | ||
| event-path: | ||
| required: true | ||
| policy-path: | ||
| required: true | ||
| mparticle-token: | ||
| required: true | ||
| rokt-token: | ||
| required: true | ||
| reviewer-token: | ||
| required: true | ||
| gate-app-id: | ||
| required: true | ||
| gate-reviewer-login: | ||
| required: true | ||
| employee-team-slug: | ||
| required: true | ||
| runs: | ||
| using: node20 | ||
| main: index.js | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.