Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a post-merge workflow to ask contributors for filling out a survey #5719

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/survey-on-merged-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Survey on Merged PR by Non-Member

on:
pull_request:
types: [closed]

jobs:
comment-on-pr:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Check if PR author is a member of the org
id: check-membership
run: |
PR_AUTHOR=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
svrnm marked this conversation as resolved.
Show resolved Hide resolved
ORG_NAME="${{ github.repository_owner }}"
ORG_MEMBERS=$(gh api "orgs/$ORG_NAME/members" --jq '.[].login')
echo "PR_AUTHOR=${PR_AUTHOR}" >> $GITHUB_ENV
echo "MEMBER_FOUND=false" >> $GITHUB_ENV
for MEMBER in $ORG_MEMBERS; do
if [[ "$PR_AUTHOR" == "$MEMBER" ]]; then
echo "MEMBER_FOUND=true" >> $GITHUB_ENV
break
fi
done

- name: Check if user is a member of the org
id: check-membership
run: |
USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
ORG="${{ github.repository_owner }}"
STATUS=$(gh api "orgs/$ORG/members/$USERNAME" --silent && echo "true" || echo "false")
if [[ "$STATUS" == "true" ]]; then
echo "MEMBER_FOUND=true" >> $GITHUB_ENV
else
echo "MEMBER_FOUND=false" >> $GITHUB_ENV
fi
env:
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}

- name: Add comment to PR if author is not a member
if: env.MEMBER_FOUND == 'false'
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
gh pr comment $PR_NUMBER --body "Thank you for your contribution! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by filling out this survey: https://forms.gle/WV58koUBGSG9HBY66"
maryliag marked this conversation as resolved.
Show resolved Hide resolved
Loading