Skip to content

Commit abc85c1

Browse files
maryliagotelbot[bot]jaydeluca
authored
chore: add workflow for surveys of non-members (#14581)
Co-authored-by: otelbot <[email protected]> Co-authored-by: Jay DeLuca <[email protected]>
1 parent a278255 commit abc85c1

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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=open-telemetry/opentelemetry-java-instrumentation
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+
permissions:
19+
contents: write
20+
pull-requests: write
21+
if: github.event.pull_request.merged == true
22+
steps:
23+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24+
- uses: actions/create-github-app-token@v1
25+
id: otelbot-token
26+
with:
27+
app-id: ${{ vars.OTELBOT_APP_ID }}
28+
private-key: ${{ secrets.OTELBOT_RIVATE_KEY }}
29+
- name: Check if user is a member of the org
30+
id: check-membership
31+
run: |
32+
USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
33+
ORG="${{ github.repository_owner }}"
34+
STATUS=$(gh api "orgs/$ORG/members/$USERNAME" --silent && echo "true" || echo "false")
35+
if [[ "$STATUS" == "true" ]]; then
36+
echo "MEMBER_FOUND=true" >> $GITHUB_ENV
37+
else
38+
echo "MEMBER_FOUND=false" >> $GITHUB_ENV
39+
fi
40+
env:
41+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
42+
43+
- name: Add comment to PR if author is not a member
44+
if: env.MEMBER_FOUND == 'false'
45+
run: |
46+
USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
47+
gh pr comment ${PR_NUM} --repo open-telemetry/opentelemetry-java-instrumentation --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})."
48+
env:
49+
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}

0 commit comments

Comments
 (0)