Skip to content

Commit d7e1e68

Browse files
committed
wip: tighten up check-label logic
Signed-off-by: Nick Hale <[email protected]>
1 parent bd5a521 commit d7e1e68

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

.github/workflows/smoke.yaml

+31-18
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,41 @@ jobs:
2323
- name: Check if PR author is a member of the organization or has the run-smoke label
2424
id: check
2525
run: |
26-
if [ "${{ github.event_name }}" == "push" ]; then
27-
echo "run_smoke_tests=true" >> $GITHUB_OUTPUT
28-
exit 0
29-
fi
26+
case "${{ github.event_name }}" in
27+
push)
28+
# Run smoke tests for push to base repo
29+
echo "run_smoke_tests=true" >> $GITHUB_OUTPUT
30+
exit 0
31+
;;
32+
workflow_dispatch)
33+
# Run smoke tests for manual runs against base branch
34+
echo "run_smoke_tests=true" >> $GITHUB_OUTPUT
35+
exit 0
36+
;;
37+
pull_request_target)
38+
ORG="gptscript-ai"
39+
AUTHOR="${{ github.event.pull_request.user.login }}"
3040
31-
ORG="gptscript-ai"
32-
USERNAME="${{ github.event.pull_request.user.login }}"
33-
RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
34-
"https://api.github.com/orgs/$ORG/members/$USERNAME")
41+
# Check for org membership
42+
MEMBERSHIP_RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
43+
"https://api.github.com/orgs/$ORG/members/$AUTHOR")
3544
36-
if [ "$RESPONSE" != "{}" ]; then
37-
echo "run_smoke_tests=true" >> $GITHUB_OUTPUT
38-
exit 0
39-
fi
45+
if [ "$MEMBERSHIP_RESPONSE_CODE" -eq 204 ]; then
46+
echo "run_smoke_tests=true" >> $GITHUB_OUTPUT
47+
exit 0
48+
fi
4049
41-
LABELS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
42-
"https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/issues/${{ github.event.pull_request.number }}/labels" | jq -r '.[].name')
50+
# Check for "run-smoke" label
51+
LABELS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
52+
"https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/issues/${{ github.event.pull_request.number }}/labels" | jq -r '.[].name')
53+
if echo "$LABELS" | grep -q "run-smoke"; then
54+
# Run smoke tests for PR with the "run-smoke" label
55+
echo "run_smoke_tests=true" >> $GITHUB_OUTPUT
56+
exit 0
57+
fi
4358
44-
if echo "$LABELS" | grep -q "run-smoke"; then
45-
echo "run_smoke_tests=true" >> $GITHUB_OUTPUT
46-
exit 0
47-
fi
59+
;;
60+
esac
4861
4962
echo "run_smoke_tests=false" >> $GITHUB_OUTPUT
5063

0 commit comments

Comments
 (0)