Skip to content
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

Allow maintainers to opt-out of perf workflow approval requests #15468

Closed
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 .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@
/.github/ @jed326 @peternied

/MAINTAINERS.md @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @dblock @dbwiddis @gaobinlong @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @peternied @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah

# Workflow specific approvals checks
/workflows/performance-benchmarks @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @dblock @dbwiddis @gaobinlong @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
20 changes: 20 additions & 0 deletions .github/actions/workflow-approvers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: 'Get the list of approvers for a workflow'

inputs:
workflow-name:
description: 'The name of the workflow to check for approvals, e.g. performance-benchmarks'
required: true

outputs:
workflow-approvers:
description: 'The list of approvers for this workflow'
value: ${{ steps.extract-approvers.outputs.workflow-approvers }}

runs:
using: "composite"
steps:
- id: extract-approvers
shell: bash
run: |
approvers=$(grep "/workflows/${{ inputs.workflow-name }}" .github/CODEOWNERS | cut -d' ' -f2- | sed 's/@//g' | tr ' ' ',')
echo "approvers=$approvers" >> $GITHUB_ENV
23 changes: 6 additions & 17 deletions .github/workflows/benchmark-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,29 +107,18 @@ jobs:
headRefSha=$(echo '${{ steps.get_pr.outputs.result }}' | jq -r '.headRefSha')
echo "prHeadRepo=$headRepo" >> $GITHUB_ENV
echo "prHeadRefSha=$headRefSha" >> $GITHUB_ENV
- id: get_approvers
uses: actions/github-script@v7
- id: workflow_approvers
uses: ./.github/actions/get-workflow-approvers
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
// Get the collaborators - filtered to maintainer permissions
const maintainersResponse = await github.request('GET /repos/{owner}/{repo}/collaborators', {
owner: context.repo.owner,
repo: context.repo.repo,
permission: 'maintain',
affiliation: 'all',
per_page: 100
});
return maintainersResponse.data.map(item => item.login).join(', ');
workflow-name: 'performance-benchmarks'
- uses: trstringer/manual-approval@v1
if: (!contains(steps.get_approvers.outputs.result, github.event.comment.user.login))
if: (!contains(steps.workflow_approvers.outputs.result, github.event.comment.user.login))
with:
secret: ${{ github.TOKEN }}
approvers: ${{ steps.get_approvers.outputs.result }}
approvers: ${{ steps.workflow_approvers.outputs.result }}
minimum-approvals: 1
issue-title: 'Request to approve/deny benchmark run for PR #${{ env.PR_NUMBER }}'
issue-body: "Please approve or deny the benchmark run for PR #${{ env.PR_NUMBER }}"
issue-body: "Please approve or deny the benchmark run for PR #${{ env.PR_NUMBER }}, please update [CODEOWNERS](../tree/main/.github/CODEOWNERS) to opt-out of future workflow approval requests."
exclude-workflow-initiator-as-approver: false
- name: Checkout PR Repo
uses: actions/checkout@v4
Expand Down
Loading