Skip to content

Commit 9fe3269

Browse files
authored
Fix typo in survey workflow and exclude bots (#14595)
1 parent 509fbe1 commit 9fe3269

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

.github/workflows/survey-on-merged-pr.yml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,34 @@ jobs:
1515
comment-on-pr:
1616
name: Add survey to PR if author is not a member
1717
runs-on: ubuntu-latest
18-
permissions:
19-
contents: write
20-
pull-requests: write
2118
if: github.event.pull_request.merged == true
2219
steps:
23-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
24-
- uses: actions/create-github-app-token@v1
20+
- uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
2521
id: otelbot-token
2622
with:
2723
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
24+
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
25+
26+
- name: Add survey comment if author is not a member or bot
3127
run: |
32-
USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
28+
USERNAME="${{ github.event.pull_request.user.login }}"
29+
USER_TYPE="${{ github.event.pull_request.user.type }}"
3330
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
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
3942
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})."
4047
env:
4148
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)