Skip to content

Commit 09154c6

Browse files
allowing backport prs to skip approval (#3132) (#3135)
* allowing backport prs to skip approval Signed-off-by: Dhrubo Saha <[email protected]> * updating the condition Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]> (cherry picked from commit ff0a341) Co-authored-by: Dhrubo Saha <[email protected]>
1 parent d52e518 commit 09154c6

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
name: Check if the workflow require approval
2+
name: Check if the workflow requires approval
33
on:
44
workflow_call:
55
outputs:
66
is-require-approval:
7-
description: The ci image version for linux build
7+
description: The CI image version for Linux build
88
value: ${{ jobs.Require-Approval.outputs.output-is-require-approval }}
99

1010
jobs:
@@ -20,17 +20,27 @@ jobs:
2020
id: step-is-require-approval
2121
run: |
2222
github_event=${{ github.event_name }}
23-
if [[ "$github_event" = "push" ]]; then
24-
echo "Push event does not need approval"
23+
author=${{ github.event.pull_request.user.login }}
24+
25+
if [[ "$github_event" == "push" ]]; then
26+
echo "Push event does not need approval."
2527
echo "is-require-approval=ml-commons-cicd-env" >> $GITHUB_OUTPUT
2628
else
27-
approvers=$(cat .github/CODEOWNERS | grep @ | tr -d '* ' | sed 's/@/,/g' | sed 's/,//1')
28-
author=${{ github.event.pull_request.user.login }}
29-
if [[ "$approvers" =~ "$author" ]]; then
30-
echo "$author is in the approval list"
29+
# Handle Pull Request events
30+
31+
# Check if the PR is triggered by opensearch-trigger-bot
32+
if [[ "$github_event" == "pull_request" ]] && [[ "$author" == "opensearch-trigger-bot[bot]" ]]; then
33+
echo "PR triggered by opensearch-trigger-bot. No approval needed."
3134
echo "is-require-approval=ml-commons-cicd-env" >> $GITHUB_OUTPUT
3235
else
33-
echo "$author is not in the approval list"
34-
echo "is-require-approval=ml-commons-cicd-env-require-approval" >> $GITHUB_OUTPUT
36+
# Check if the author is in the approvers list
37+
approvers=$(cat .github/CODEOWNERS | grep @ | tr -d '* ' | sed 's/@/,/g' | sed 's/,//1')
38+
if [[ "$approvers" =~ "$author" ]]; then
39+
echo "$author is in the approval list."
40+
echo "is-require-approval=ml-commons-cicd-env" >> $GITHUB_OUTPUT
41+
else
42+
echo "$author is not in the approval list."
43+
echo "is-require-approval=ml-commons-cicd-env-require-approval" >> $GITHUB_OUTPUT
44+
fi
3545
fi
3646
fi

0 commit comments

Comments
 (0)