Skip to content

Commit 570aeda

Browse files
maryliagtrask
andauthored
chore: add workflow for surveys of non-members (#7640)
Co-authored-by: Trask Stalnaker <[email protected]>
1 parent 68fcd44 commit 570aeda

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Survey on Merged PR by Non-Member
2+
3+
on:
4+
pull_request_target:
5+
types: [closed]
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
PR_NUM: ${{ github.event.pull_request.number }}
12+
SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=${{ github.repository }}
13+
14+
jobs:
15+
comment-on-pr:
16+
name: Add survey to PR if author is not a member
17+
runs-on: ubuntu-latest
18+
if: github.event.pull_request.merged == true
19+
steps:
20+
- uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
21+
id: otelbot-token
22+
with:
23+
app-id: ${{ vars.OTELBOT_APP_ID }}
24+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
25+
26+
- name: Add survey comment if author is not a member or bot
27+
run: |
28+
USERNAME="${{ github.event.pull_request.user.login }}"
29+
USER_TYPE="${{ github.event.pull_request.user.type }}"
30+
ORG="${{ github.repository_owner }}"
31+
32+
# Skip if user is a bot
33+
if [[ "$USER_TYPE" == "Bot" ]]; then
34+
echo "Skipping survey for bot user: $USERNAME"
35+
exit 0
36+
fi
37+
38+
# Skip if user is an org member
39+
if gh api "orgs/$ORG/members/$USERNAME" --silent; then
40+
echo "Skipping survey for org member: $USERNAME"
41+
exit 0
42+
fi
43+
44+
# Add survey comment for external contributor
45+
echo "Adding survey comment for external contributor: $USERNAME"
46+
gh pr comment ${PR_NUM} --repo ${{ github.repository }} --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})."
47+
env:
48+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}

0 commit comments

Comments
 (0)