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

allowing backport prs to skip approval #3132

Merged
merged 2 commits into from
Oct 21, 2024
Merged
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
30 changes: 20 additions & 10 deletions .github/workflows/require-approval.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: Check if the workflow require approval
name: Check if the workflow requires approval
on:
workflow_call:
outputs:
is-require-approval:
description: The ci image version for linux build
description: The CI image version for Linux build
value: ${{ jobs.Require-Approval.outputs.output-is-require-approval }}

jobs:
Expand All @@ -20,17 +20,27 @@ jobs:
id: step-is-require-approval
run: |
github_event=${{ github.event_name }}
if [[ "$github_event" = "push" ]]; then
echo "Push event does not need approval"
author=${{ github.event.pull_request.user.login }}

if [[ "$github_event" == "push" ]]; then
echo "Push event does not need approval."
echo "is-require-approval=ml-commons-cicd-env" >> $GITHUB_OUTPUT
else
approvers=$(cat .github/CODEOWNERS | grep @ | tr -d '* ' | sed 's/@/,/g' | sed 's/,//1')
author=${{ github.event.pull_request.user.login }}
if [[ "$approvers" =~ "$author" ]]; then
echo "$author is in the approval list"
# Handle Pull Request events

# Check if the PR is triggered by opensearch-trigger-bot
if [[ "$github_event" == "pull_request" ]] && [[ "$author" == "opensearch-trigger-bot[bot]" ]]; then
echo "PR triggered by opensearch-trigger-bot. No approval needed."
echo "is-require-approval=ml-commons-cicd-env" >> $GITHUB_OUTPUT
else
echo "$author is not in the approval list"
echo "is-require-approval=ml-commons-cicd-env-require-approval" >> $GITHUB_OUTPUT
# Check if the author is in the approvers list
approvers=$(cat .github/CODEOWNERS | grep @ | tr -d '* ' | sed 's/@/,/g' | sed 's/,//1')
if [[ "$approvers" =~ "$author" ]]; then
echo "$author is in the approval list."
echo "is-require-approval=ml-commons-cicd-env" >> $GITHUB_OUTPUT
else
echo "$author is not in the approval list."
echo "is-require-approval=ml-commons-cicd-env-require-approval" >> $GITHUB_OUTPUT
fi
fi
fi
Loading