Skip to content

Commit e7865c6

Browse files
authored
chore: add workflow for surveys of non-members (#5411)
1 parent bc6c4eb commit e7865c6

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Survey on Merged PR by Non-Member
2+
3+
on:
4+
pull_request_target:
5+
types: [closed]
6+
7+
env:
8+
PR_NUM: ${{ github.event.pull_request.number }}
9+
SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=open-telemetry/opentelemetry-js
10+
11+
jobs:
12+
comment-on-pr:
13+
name: Add survey to PR if author is not a member
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
if: github.event.pull_request.merged == true
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Check if user is a member of the org
22+
id: check-membership
23+
run: |
24+
USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
25+
ORG="${{ github.repository_owner }}"
26+
STATUS=$(gh api "orgs/$ORG/members/$USERNAME" --silent && echo "true" || echo "false")
27+
if [[ "$STATUS" == "true" ]]; then
28+
echo "MEMBER_FOUND=true" >> $GITHUB_ENV
29+
else
30+
echo "MEMBER_FOUND=false" >> $GITHUB_ENV
31+
fi
32+
env:
33+
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
34+
35+
- name: Add comment to PR if author is not a member
36+
if: env.MEMBER_FOUND == 'false'
37+
run: |
38+
gh pr comment ${PR_NUM} --repo open-telemetry/opentelemetry.io --body "Thank you for your contribution @${USERNAME}! 🎉 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})."
39+
env:
40+
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}

0 commit comments

Comments
 (0)