Skip to content

Commit bcd0976

Browse files
[build] use rulesets to restrict and unrestrict trunk during release window (#16941)
* [build] use rulesets to restrict and unrestrict trunk during release window * [build] add empty permissions to restrict-trunk workflow * create slack message if release fails --------- Co-authored-by: Copilot <[email protected]>
1 parent 47dbd0d commit bcd0976

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

.github/workflows/pre-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
update-rust:
2323
name: Update Rust Version
2424
runs-on: ubuntu-latest
25+
if: github.event.repository.fork == false
2526
steps:
2627
- name: "Checkout repo"
2728
uses: actions/checkout@v4

.github/workflows/release.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,18 @@ jobs:
139139
omitBodyDuringUpdate: true
140140
omitNameDuringUpdate: true
141141

142+
unrestrict-trunk:
143+
name: Unrestrict Trunk Branch
144+
needs: [github-release]
145+
if: always()
146+
uses: ./.github/workflows/restrict-trunk.yml
147+
with:
148+
restrict: false
149+
secrets: inherit
150+
142151
update-version:
143152
name: Reset Versions to Nightly
144-
needs: [stage, docs]
153+
needs: [stage, docs, unrestrict-trunk]
145154
runs-on: ubuntu-latest
146155
permissions:
147156
contents: write
@@ -165,3 +174,27 @@ jobs:
165174
run: |
166175
git commit -m "[build] Reset versions to nightly after ${{ needs.stage.outputs.tag }} release"
167176
git push
177+
178+
on-release-failure:
179+
name: On Release Failure
180+
runs-on: ubuntu-latest
181+
needs: [stage, authorize, publish, docs, github-release, unrestrict-trunk, update-version]
182+
if: failure()
183+
steps:
184+
- uses: actions/checkout@v4
185+
- name: Slack Notification
186+
uses: rtCamp/action-slack-notify@v2
187+
env:
188+
SLACK_ICON_EMOJI: ":rotating_light:"
189+
SLACK_COLOR: failure
190+
SLACK_CHANNEL: selenium-tlc
191+
SLACK_USERNAME: GitHub Workflows
192+
SLACK_TITLE: Release failed
193+
SLACK_MESSAGE: >
194+
Selenium Published: ${{ needs.publish.result }},
195+
Docs Updated: ${{ needs.docs.result }},
196+
GitHub Release Published: ${{ needs.github-release.result }},
197+
Trunk Unlocked: ${{ needs.unrestrict-trunk.result }},
198+
Nightly Version Updated: ${{ needs.update-version.result }}
199+
MSG_MINIMAL: actions url
200+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Manage Trunk Restrictions
2+
3+
permissions: {}
4+
5+
concurrency:
6+
group: manage-trunk-restrictions
7+
cancel-in-progress: false
8+
9+
on:
10+
pull_request:
11+
types: [ready_for_review, closed]
12+
branches:
13+
- trunk
14+
workflow_dispatch:
15+
inputs:
16+
restrict:
17+
description: 'Restrict trunk branch'
18+
required: true
19+
type: boolean
20+
workflow_call:
21+
inputs:
22+
restrict:
23+
description: 'Restrict trunk branch'
24+
required: true
25+
type: boolean
26+
27+
jobs:
28+
manage-trunk:
29+
name: Manage Trunk Branch
30+
runs-on: ubuntu-latest
31+
if: |
32+
github.event.repository.fork == false &&
33+
(github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' ||
34+
(startsWith(github.event.pull_request.head.ref, 'release-preparation-') &&
35+
(github.event.action == 'ready_for_review' ||
36+
(github.event.action == 'closed' && github.event.pull_request.merged == false))))
37+
strategy:
38+
matrix:
39+
ruleset_id:
40+
- 11911909 # Release In Progress Access (restrict updates to trunk to release managers)
41+
- 11912022 # Release In Progress Flow (requires branches to be up to date before merging)
42+
env:
43+
TRUNK_RESTRICTED: ${{ inputs.restrict || github.event.action == 'ready_for_review' }}
44+
steps:
45+
- name: Update ruleset enforcement
46+
uses: octokit/[email protected]
47+
with:
48+
route: PUT /repos/{owner}/{repo}/rulesets/{ruleset_id}
49+
owner: ${{ github.repository_owner }}
50+
repo: ${{ github.event.repository.name }}
51+
ruleset_id: ${{ matrix.ruleset_id }}
52+
enforcement: ${{ env.TRUNK_RESTRICTED == 'true' && 'active' || 'disabled' }}
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.SELENIUM_CI_TOKEN }}

0 commit comments

Comments
 (0)