Skip to content

Commit caebb85

Browse files
committed
main: check for soup approver for the whole list of approvers and not just the current one
1 parent f74cafb commit caebb85

2 files changed

Lines changed: 32 additions & 13 deletions

File tree

.github/workflows/soup-approval-verification-workflow.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,30 +161,46 @@ jobs:
161161
env:
162162
ALLOWED_APPROVERS: ${{ vars.SOUP_APPROVERS }}
163163
run: |
164-
APPROVED_BY="${{ github.event.review.user.login }}"
164+
PR_NUMBER="${{ github.event.pull_request.number }}"
165+
REPO="${{ github.repository }}"
166+
167+
echo "Fetching all approvers for PR #$PR_NUMBER in $REPO..."
168+
169+
ALL_APPROVERS=$(curl -s -H "Authorization: Bearer $GH_API_TOKEN" \
170+
"https://api.github.com/repos/$REPO/pulls/$PR_NUMBER/reviews" \
171+
| jq -r '.[] | select(.state == "APPROVED") | .user.login' | sort -u)
172+
173+
if [ -z "$ALL_APPROVERS" ]; then
174+
echo "::warning::No approvals found yet for PR #$PR_NUMBER"
175+
exit 1
176+
fi
177+
178+
echo "Found approvers: $ALL_APPROVERS"
165179
166180
if [ -n "$ALLOWED_APPROVERS" ]; then
167-
echo "Checking if $APPROVED_BY is in allowed approvers list..."
181+
echo "Checking allowed approvers list: $ALLOWED_APPROVERS"
168182
169183
IFS=',' read -ra APPROVER_LIST <<< "$ALLOWED_APPROVERS"
170-
APPROVER_FOUND=false
171184
172-
for approver in "${APPROVER_LIST[@]}"; do
173-
if [ "$(echo "$approver" | xargs)" = "$APPROVED_BY" ]; then
174-
APPROVER_FOUND=true
175-
break
176-
fi
185+
AUTHORIZED_APPROVERS=()
186+
for approver in $ALL_APPROVERS; do
187+
for allowed in "${APPROVER_LIST[@]}"; do
188+
if [ "$(echo "$allowed" | xargs)" = "$approver" ]; then
189+
AUTHORIZED_APPROVERS+=("$approver")
190+
fi
191+
done
177192
done
178193
179-
if [ "$APPROVER_FOUND" = false ]; then
180-
echo "::error::❌ $APPROVED_BY is not in the allowed approvers list: $ALLOWED_APPROVERS"
194+
if [ ${#AUTHORIZED_APPROVERS[@]} -eq 0 ]; then
195+
echo "::error::❌ None of the approvers ($ALL_APPROVERS) are in the allowed list: $ALLOWED_APPROVERS"
181196
echo "Approval will not be recorded."
182197
exit 1
183198
fi
184199
185-
echo "✅ $APPROVED_BY is authorized to approve soups"
200+
echo "✅ Authorized approvers found: ${AUTHORIZED_APPROVERS[*]}"
186201
else
187202
echo "⚠️ No ALLOWED_APPROVERS configured - allowing all approvals"
203+
AUTHORIZED_APPROVERS=($ALL_APPROVERS)
188204
fi
189205
190206
APPROVED_ON=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
@@ -201,7 +217,10 @@ jobs:
201217
continue
202218
fi
203219
204-
APPROVER_INFO=$(curl -s -H "Authorization: Bearer $GH_API_TOKEN" "https://api.github.com/users/$APPROVED_BY")
220+
APPROVED_BY="${AUTHORIZED_APPROVERS[0]}"
221+
222+
APPROVER_INFO=$(curl -s -H "Authorization: Bearer $GH_API_TOKEN" \
223+
"https://api.github.com/users/$APPROVED_BY")
205224
APPROVER_NAME=$(echo "$APPROVER_INFO" | jq -r '.name // empty')
206225
if [ -z "$APPROVER_NAME" ]; then
207226
APPROVER_NAME="$APPROVED_BY"

.github/workflows/soup-packages-cve-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
run: git clone git@github.com:QuickBirdEng/action-scripts.git action-scripts && mv action-scripts/* .
1616
- name: Run CVE Check for Packages
1717
shell: bash
18-
run: bash packages-cve-check.sh
18+
run: bash packages-cve-check.sh && cat cve-report.json
1919
- name: Upload CVE Check for Packages Report
2020
uses: actions/upload-artifact@v4
2121
with:

0 commit comments

Comments
 (0)