Skip to content

Toggling who can bypass the merge queue with the deployment lock #5837

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

Merged
merged 3 commits into from
Mar 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"features": {
"ghcr.io/devcontainers/features/sshd:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/github-cli": {
"version": "latest"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to add gh cli command to the codespace

}
},
"hostRequirements": {
Expand Down
73 changes: 46 additions & 27 deletions .github/workflows/lock-release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Lock Release Pull Request
name: Toggle Release Lock

on:
release:
types: [released]
workflow_dispatch:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to unlock when a release is merged

inputs:
action:
Expand All @@ -13,7 +15,8 @@ on:

jobs:
lock:
name: Toggle Release Lock
if: ${{ github.event.inputs.action == 'lock' }}
name: Lock the release
runs-on: ubuntu-latest
steps:
- name: Get App Token
Expand All @@ -24,36 +27,52 @@ jobs:
owner: primer
repositories: react
private-key: ${{ secrets.PRIMER_APP_PRIVATE_KEY_SHARED }}
- name: Toggle Rule > Release Conductor
- name: Toggle rulesets
run: |
enforcement=$([ "${{ github.event.inputs.action }}" == "lock" ] && echo "active" || echo "disabled")
# Allow react-release-conductor to bypass merge queue
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/primer/react/rulesets/4089335 \
-F "bypass_actors[][actor_id]=12276524" \
-f "bypass_actors[][actor_type]=Team" \
-f "bypass_actors[][bypass_mode]=always"
gh api \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lets react-release-conductor bypass the merge queue when lock is in effect. We have to do this because if we leave the merge queue on the checkbox won't showup to bypass unless the conductor can also bypass the queue.

--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/primer/react/rulesets/3801256 \
-f "enforcement=active"
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

unlock:
if: ${{ github.event.inputs.action == 'unlock' || github.event.action == 'released' }}
name: Unlock the release
runs-on: ubuntu-latest
steps:
- name: Get App Token
uses: actions/create-github-app-token@21cfef2b496dd8ef5b904c159339626a10ad380e
id: app-token
with:
app-id: ${{ vars.PRIMER_APP_ID_SHARED }}
owner: primer
repositories: react
private-key: ${{ secrets.PRIMER_APP_PRIVATE_KEY_SHARED }}
- name: Toggle rulesets
run: |
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/primer/react/rulesets/4089335 \
-F "bypass_actors[]"
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/primer/react/rulesets/3801256 \
-f "enforcement=${enforcement}"
-f "enforcement=disabled"
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
# - name: Toggle Rule > Update Before Merging
# run: |
# enforcement=$([ "${{ github.event.inputs.action }}" == "lock" ] && echo "active" || echo "disabled")
# gh api \
# --method PUT \
# -H "Accept: application/vnd.github+json" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# /repos/primer/react/rulesets/4089341 \
# -f "enforcement=${enforcement}"
# env:
# GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
# - name: Toggle Rule > Merge Queue
# run: |
# enforcement=$([ "${{ github.event.inputs.action }}" == "lock" ] && echo "disabled" || echo "active")
# gh api \
# --method PUT \
# -H "Accept: application/vnd.github+json" \
# -H "X-GitHub-Api-Version: 2022-11-28" \
# /repos/primer/react/rulesets/4089335 \
# -f "enforcement=${enforcement}"
# env:
# GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
Loading