From ea4c8f630d49144c8d45cc49b7c30c7823703305 Mon Sep 17 00:00:00 2001 From: maryliag Date: Thu, 4 Sep 2025 14:31:00 -0400 Subject: [PATCH 1/8] chore: add workflow for surveys of non-members --- .github/workflows/survey-on-merged-pr.yml | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/survey-on-merged-pr.yml diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml new file mode 100644 index 00000000000..95e2c629d4a --- /dev/null +++ b/.github/workflows/survey-on-merged-pr.yml @@ -0,0 +1,44 @@ +name: Survey on Merged PR by Non-Member + +on: + pull_request_target: + types: [closed] + +permissions: + contents: read + +env: + PR_NUM: ${{ github.event.pull_request.number }} + SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=open-telemetry/opentelemetry-java + +jobs: + comment-on-pr: + name: Add survey to PR if author is not a member + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + if: github.event.pull_request.merged == true + steps: + - uses: actions/checkout@v5 + - 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: | + USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH") + gh pr comment ${PR_NUM} --repo open-telemetry/opentelemetry-java --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})." + env: + GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} \ No newline at end of file From e1f0c44516736b695a2c70488592bd6b31137644 Mon Sep 17 00:00:00 2001 From: maryliag Date: Thu, 4 Sep 2025 19:50:38 -0400 Subject: [PATCH 2/8] update token --- .github/workflows/survey-on-merged-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml index 95e2c629d4a..d681b472a58 100644 --- a/.github/workflows/survey-on-merged-pr.yml +++ b/.github/workflows/survey-on-merged-pr.yml @@ -33,7 +33,7 @@ jobs: echo "MEMBER_FOUND=false" >> $GITHUB_ENV fi env: - GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} - name: Add comment to PR if author is not a member if: env.MEMBER_FOUND == 'false' @@ -41,4 +41,4 @@ jobs: USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH") gh pr comment ${PR_NUM} --repo open-telemetry/opentelemetry-java --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})." env: - GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} \ No newline at end of file + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} \ No newline at end of file From aa7ab0b70494b9988c12a0e7b7fb497154d0f1b5 Mon Sep 17 00:00:00 2001 From: maryliag Date: Thu, 4 Sep 2025 19:58:30 -0400 Subject: [PATCH 3/8] add step --- .github/workflows/survey-on-merged-pr.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml index d681b472a58..6f8c72b1ee6 100644 --- a/.github/workflows/survey-on-merged-pr.yml +++ b/.github/workflows/survey-on-merged-pr.yml @@ -20,7 +20,12 @@ jobs: pull-requests: write if: github.event.pull_request.merged == true steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.OTELBOT_APP_ID }} + private-key: ${{ secrets.OTELBOT_RIVATE_KEY }} - name: Check if user is a member of the org id: check-membership run: | From 0447fa071e2cb75af436df22ff9595ef0b9b6493 Mon Sep 17 00:00:00 2001 From: maryliag Date: Thu, 4 Sep 2025 20:14:39 -0400 Subject: [PATCH 4/8] fix id --- .github/workflows/survey-on-merged-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml index 6f8c72b1ee6..45028674d91 100644 --- a/.github/workflows/survey-on-merged-pr.yml +++ b/.github/workflows/survey-on-merged-pr.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - uses: actions/create-github-app-token@v1 - id: app-token + id: otelbot-token with: app-id: ${{ vars.OTELBOT_APP_ID }} private-key: ${{ secrets.OTELBOT_RIVATE_KEY }} From 9463a174731facb3b39fa13fe0a9f5063d032b68 Mon Sep 17 00:00:00 2001 From: maryliag Date: Fri, 5 Sep 2025 11:39:36 -0400 Subject: [PATCH 5/8] fix typo --- .github/workflows/survey-on-merged-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml index 45028674d91..b3dde1429b0 100644 --- a/.github/workflows/survey-on-merged-pr.yml +++ b/.github/workflows/survey-on-merged-pr.yml @@ -21,11 +21,11 @@ jobs: if: github.event.pull_request.merged == true steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - uses: actions/create-github-app-token@v1 + - uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1 id: otelbot-token with: app-id: ${{ vars.OTELBOT_APP_ID }} - private-key: ${{ secrets.OTELBOT_RIVATE_KEY }} + private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }} - name: Check if user is a member of the org id: check-membership run: | From a07bd9d74d016d8669b2bf02df3271e9b813c229 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 5 Sep 2025 12:33:59 -0700 Subject: [PATCH 6/8] Align with Java instrumentation workflow --- .github/workflows/survey-on-merged-pr.yml | 41 +++++++++++------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml index b3dde1429b0..c82d748948c 100644 --- a/.github/workflows/survey-on-merged-pr.yml +++ b/.github/workflows/survey-on-merged-pr.yml @@ -9,41 +9,40 @@ permissions: env: PR_NUM: ${{ github.event.pull_request.number }} - SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=open-telemetry/opentelemetry-java + SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=open-telemetry/opentelemetry-java-instrumentation jobs: comment-on-pr: name: Add survey to PR if author is not a member runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write if: github.event.pull_request.merged == true steps: - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1 id: otelbot-token with: app-id: ${{ vars.OTELBOT_APP_ID }} private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }} - - name: Check if user is a member of the org - id: check-membership + + - name: Add survey comment if author is not a member or bot run: | - USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH") + USERNAME="${{ github.event.pull_request.user.login }}" + USER_TYPE="${{ github.event.pull_request.user.type }}" 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 + + # Skip if user is a bot + if [[ "$USER_TYPE" == "Bot" ]]; then + echo "Skipping survey for bot user: $USERNAME" + exit 0 + fi + + # Skip if user is an org member + if gh api "orgs/$ORG/members/$USERNAME" --silent; then + echo "Skipping survey for org member: $USERNAME" + exit 0 fi + + # Add survey comment for external contributor + echo "Adding survey comment for external contributor: $USERNAME" + 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})." env: GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} - - - name: Add comment to PR if author is not a member - if: env.MEMBER_FOUND == 'false' - run: | - USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH") - gh pr comment ${PR_NUM} --repo open-telemetry/opentelemetry-java --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})." - env: - GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} \ No newline at end of file From 4642ab95a3a24cbc1fb562126c0640f07a52cf59 Mon Sep 17 00:00:00 2001 From: Marylia Gutierrez Date: Fri, 5 Sep 2025 15:59:05 -0400 Subject: [PATCH 7/8] Update .github/workflows/survey-on-merged-pr.yml --- .github/workflows/survey-on-merged-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml index c82d748948c..f9231746443 100644 --- a/.github/workflows/survey-on-merged-pr.yml +++ b/.github/workflows/survey-on-merged-pr.yml @@ -9,7 +9,7 @@ permissions: env: PR_NUM: ${{ github.event.pull_request.number }} - SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=open-telemetry/opentelemetry-java-instrumentation + SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=open-telemetry/opentelemetry-java jobs: comment-on-pr: From 3e2f302c20eb5abc5232462023f8d7b43f6fb0b5 Mon Sep 17 00:00:00 2001 From: Marylia Gutierrez Date: Fri, 5 Sep 2025 19:53:16 -0400 Subject: [PATCH 8/8] Update .github/workflows/survey-on-merged-pr.yml Co-authored-by: Trask Stalnaker --- .github/workflows/survey-on-merged-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml index f9231746443..4d9ebcdee5f 100644 --- a/.github/workflows/survey-on-merged-pr.yml +++ b/.github/workflows/survey-on-merged-pr.yml @@ -9,7 +9,7 @@ permissions: env: PR_NUM: ${{ github.event.pull_request.number }} - SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=open-telemetry/opentelemetry-java + SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=${{ github.repository }} jobs: comment-on-pr: