|
1 | 1 | name: Survey on Merged PR by Non-Member
|
2 | 2 |
|
3 | 3 | on:
|
4 |
| - issues: |
| 4 | + pull_request_target: |
| 5 | + branches: [main] |
5 | 6 | types: [closed]
|
6 | 7 |
|
7 | 8 | permissions: {}
|
8 | 9 |
|
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 |
| - |
13 | 10 | jobs:
|
14 | 11 | comment-on-pr:
|
15 | 12 | name: Add survey to PR if author is not a member
|
16 |
| - runs-on: ubuntu-latest |
17 | 13 | permissions:
|
18 |
| - contents: write |
19 | 14 | 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) |
21 | 17 | 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) |
25 | 21 | 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 |
52 | 23 | 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})." |
54 | 25 | 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