Skip to content

Commit 5bd9a40

Browse files
sutaakaropenshift-merge-bot[bot]
authored andcommitted
Use list of users as lake gate approvers
1 parent 9d3710e commit 5bd9a40

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

.github/workflows/approve-lake-gate.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ permissions:
1616
jobs:
1717
approve-lake-gate:
1818
runs-on: ubuntu-latest
19-
if: github.event.issue.pull_request && contains(github.event.comment.body, '/approve') && contains(github.event.issue.labels.*.name, 'lake-gate') && github.event.comment.author_association == 'OWNER'
19+
if: github.event.issue.pull_request && contains(github.event.comment.body, '/approve') && contains(github.event.issue.labels.*.name, 'lake-gate')
2020

2121
steps:
2222
- name: Checkout repository
@@ -25,6 +25,40 @@ jobs:
2525
fetch-depth: 0
2626
token: ${{ secrets.GITHUB_TOKEN }}
2727

28+
- name: Disallow forks
29+
run: |
30+
set -euo pipefail
31+
PR_NUMBER="${{ github.event.issue.number }}"
32+
IS_CROSS=$(gh pr view "$PR_NUMBER" --json isCrossRepository --jq '.isCrossRepository')
33+
if [ "$IS_CROSS" = "true" ]; then
34+
gh pr comment "$PR_NUMBER" --body "❌ Cannot approve: fork-based PRs are not supported for lake-gate. Please open the PR from a branch in the main repository."
35+
exit 1
36+
fi
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Check if user is authorized to approve
41+
run: |
42+
set -euo pipefail
43+
COMMENT_USER="${{ github.event.comment.user.login }}"
44+
echo "Checking authorization for user: $COMMENT_USER"
45+
46+
# Check if the user is in the approve-lake-gate alias in OWNERS_ALIASES file
47+
if yq eval '.aliases.approve-lake-gate[] | select(. == "'${COMMENT_USER}'")' OWNERS_ALIASES | grep -q "${COMMENT_USER}"; then
48+
echo "✅ User ${COMMENT_USER} is authorized to approve lake-gate PRs"
49+
else
50+
echo "❌ User ${COMMENT_USER} is not authorized to approve lake-gate PRs"
51+
52+
# Show available approvers for debugging
53+
echo "Available approve-lake-gate users:"
54+
yq eval '.aliases.approve-lake-gate[]' OWNERS_ALIASES || echo "No approve-lake-gate alias found"
55+
56+
gh pr comment "${{ github.event.issue.number }}" --body "❌ @${COMMENT_USER} is not authorized to approve lake-gate PRs. Only users listed in the approve-lake-gate alias in OWNERS_ALIASES file can approve."
57+
exit 1
58+
fi
59+
env:
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
2862
- name: Configure Git
2963
run: |
3064
git config --global user.name "github-actions[bot]"

OWNERS_ALIASES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
aliases:
2+
approve-lake-gate:
3+
- abhijeet-dhumal
4+
- ChughShilpa
5+
- efazal
6+
- kapil27
7+
- sutaakar

0 commit comments

Comments
 (0)