forked from opensearch-project/ml-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Test Env Require Approval Action (opensearch-project#3005) (opens…
…earch-project#3016) * Add require approval stage so only maintainers can start CI stage without approval Signed-off-by: Peter Zhu <[email protected]> * Add more Signed-off-by: Peter Zhu <[email protected]> * Add more Signed-off-by: Peter Zhu <[email protected]> * Add old files Signed-off-by: Peter Zhu <[email protected]> * Update require-approval.yml Signed-off-by: Peter Zhu <[email protected]> --------- Signed-off-by: Peter Zhu <[email protected]> (cherry picked from commit 9de2d23) Co-authored-by: Peter Zhu <[email protected]>
- Loading branch information
1 parent
670e461
commit a364f14
Showing
2 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
name: Check if the workflow require approval | ||
on: | ||
workflow_call: | ||
outputs: | ||
is-require-approval: | ||
description: The ci image version for linux build | ||
value: ${{ jobs.Require-Approval.outputs.output-is-require-approval }} | ||
|
||
jobs: | ||
Require-Approval: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
output-is-require-approval: ${{ steps.step-is-require-approval.outputs.is-require-approval }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.base.sha }} | ||
- name: Get CodeOwner List | ||
id: step-is-require-approval | ||
run: | | ||
github_event=${{ github.event_name }} | ||
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" | ||
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 |