@@ -23,28 +23,41 @@ jobs:
23
23
- name : Check if PR author is a member of the organization or has the run-smoke label
24
24
id : check
25
25
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 }}"
30
40
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")
35
44
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
40
49
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
43
58
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
48
61
49
62
echo "run_smoke_tests=false" >> $GITHUB_OUTPUT
50
63
0 commit comments