Skip to content

Commit 3fc2378

Browse files
[Infra] Fix merged PR survey workflow (#6492)
1 parent 82ea003 commit 3fc2378

File tree

1 file changed

+13
-40
lines changed

1 file changed

+13
-40
lines changed
Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,29 @@
11
name: Survey on Merged PR by Non-Member
22

33
on:
4-
issues:
4+
pull_request_target:
5+
branches: [main]
56
types: [closed]
67

78
permissions: {}
89

9-
env:
10-
PR_URL: ${{ github.event.issue.pull_request.url }}
11-
SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=open-telemetry/opentelemetry-dotnet
12-
1310
jobs:
1411
comment-on-pr:
1512
name: Add survey to PR if author is not a member
16-
runs-on: ubuntu-latest
1713
permissions:
18-
contents: write
1914
pull-requests: write
20-
# Only run if this issue is a PR and the PR was merged
15+
runs-on: ubuntu-latest
16+
# Only run for merged pull requests by non-members users (i.e. not bots)
2117
if: |
22-
github.event.issue.pull_request != null &&
23-
github.event.issue.state == 'closed' &&
24-
github.event.issue.closed_by != null
18+
github.event.pull_request.merged &&
19+
github.event.pull_request.user.type == 'User' &&
20+
contains(fromJson('["CONTRIBUTOR", "FIRST_TIME_CONTRIBUTOR", "FIRST_TIMER"]'), github.event.pull_request.author_association)
2521
steps:
26-
- name: Get PR Info
27-
id: pr-info
28-
run: |
29-
# Get merged status and author
30-
PR_JSON=$(gh api "$PR_URL")
31-
echo "merged=$(echo "$PR_JSON" | jq -r '.merged')" >> $GITHUB_OUTPUT
32-
echo "author=$(echo "$PR_JSON" | jq -r '.user.login')" >> $GITHUB_OUTPUT
33-
env:
34-
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
35-
36-
- name: Check if user is a member of the org
37-
id: check-membership
38-
run: |
39-
ORG="${{ github.repository_owner }}"
40-
STATUS=$(gh api "orgs/$ORG/members/$USERNAME" --silent && echo "true" || echo "false")
41-
if [[ "$STATUS" == "true" ]]; then
42-
echo "MEMBER_FOUND=true" >> $GITHUB_ENV
43-
else
44-
echo "MEMBER_FOUND=false" >> $GITHUB_ENV
45-
fi
46-
env:
47-
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
48-
USERNAME: ${{ steps.pr-info.outputs.author }}
49-
50-
- name: Add comment to PR if author is not a member and PR is merged
51-
if: steps.pr-info.outputs.merged == 'true' && steps.check-membership.outputs.member_found == 'false'
22+
- name: Add comment
5223
run: |
53-
gh pr comment "$PR_URL" --body "Thank you for your contribution @${USERNAME}! :tada: We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this [survey](${SURVEY_URL})."
24+
gh pr comment "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --body "Thank you for your contribution @${USERNAME}! :tada: We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this [survey](${SURVEY_URL})."
5425
env:
55-
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
56-
USERNAME: ${{ steps.pr-info.outputs.author }}
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
PR_NUMBER: ${{ github.event.pull_request.number }}
28+
SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=${{ github.repository }}
29+
USERNAME: ${{ github.event.pull_request.user.login }}

0 commit comments

Comments
 (0)