From 8c98fd1d43a36cc378f84cabd94bb421efab0efe Mon Sep 17 00:00:00 2001 From: maryliag Date: Thu, 9 Jul 2026 13:07:41 -0400 Subject: [PATCH 1/2] workflow for survey on pr merged --- .github/workflows/survey-on-merged-pr.yml | 34 +++++++++++++++++ README.md | 1 + survey-on-merged-pr/README.md | 46 +++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 .github/workflows/survey-on-merged-pr.yml create mode 100644 survey-on-merged-pr/README.md diff --git a/.github/workflows/survey-on-merged-pr.yml b/.github/workflows/survey-on-merged-pr.yml new file mode 100644 index 000000000..dbf27a13f --- /dev/null +++ b/.github/workflows/survey-on-merged-pr.yml @@ -0,0 +1,34 @@ +# Reusable workflow — see /survey-on-merged-pr/README.md for consumer documentation. +name: Survey on Merged PR by Non-Member + +on: + workflow_call: + +permissions: {} + +env: + SURVEY_URL: https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform?entry.1540511742=${{ github.repository }} + +jobs: + comment-on-pr: + name: Add survey to PR if author is not a member + runs-on: ubuntu-latest + permissions: + pull-requests: write # for gh pr comment + if: >- + github.event.pull_request.merged == true && + github.repository_owner == 'open-telemetry' && + github.event.pull_request.user.type != 'Bot' && + github.event.pull_request.author_association != 'MEMBER' && + github.event.pull_request.author_association != 'OWNER' && + github.event.pull_request.author_association != 'COLLABORATOR' + steps: + - name: Add survey comment + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + USERNAME: ${{ github.event.pull_request.user.login }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + set -euo pipefail + gh pr comment "$PR_NUMBER" --repo "$REPO" --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})." diff --git a/README.md b/README.md index 0cc159b87..c12f92cd6 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for how to propose a new shared workf | ---- | ----------- | ---------- | | [First-time contributor](./first-time-pr/) | Reusable workflow that welcomes first-time contributors on `pull_request_target: opened`: applies a label and posts a customizable welcome comment. | Call via `uses:` from your repo's `pull_request_target` workflow. See the [First-time contributor README](./first-time-pr/README.md) for the snippet. | | [Pull Request Dashboard](./pull-request-dashboard/) | Centrally-executed workflow that builds a per-repository pull request triage dashboard (issue body, status, Slack notifications) for opted-in repositories. | Add your repository to [`repositories.json`](./.github/scripts/pull-request-dashboard/repositories.json) and follow the setup in the [workflow's README](./pull-request-dashboard/README.md). | +| [Survey on merged PR](./survey-on-merged-pr/) | Reusable workflow that posts a survey link to a merged PR when the author is a new contributor. | Call via `uses:` from your repo's `pull_request_target: closed` workflow. See the [Survey on merged PR README](./survey-on-merged-pr/README.md) for the snippet. | | [Zizmor](./zizmor/) | Static analysis of GitHub Actions workflows for security issues using [zizmor](https://github.com/zizmorcore/zizmor). | Call via `uses:` from your repo's workflow. See the [Zizmor README](./zizmor/README.md) for the snippet. | ## Maintainers diff --git a/survey-on-merged-pr/README.md b/survey-on-merged-pr/README.md new file mode 100644 index 000000000..0eed9660b --- /dev/null +++ b/survey-on-merged-pr/README.md @@ -0,0 +1,46 @@ +# Survey on merged PR (non-member) + +Reusable GitHub Actions workflow that posts a survey link to a pull request when it is merged, if the author is an external contributor (not an OpenTelemetry org member, not a repo owner or collaborator, and not a bot). Used to gather feedback from new contributors about their OpenTelemetry contribution experience. + +The survey link automatically includes the caller repository as a query parameter (`entry.1540511742=`), so responses collected in the shared OpenTelemetry Google Form are tagged with the source repo. + +## Prerequisites + +**Confirm that your repository is one of the options in the survey's first question** — a select/dropdown that identifies which repository the response is about. Open the [survey form](https://docs.google.com/forms/d/e/1FAIpQLSf2FfCsW-DimeWzdQgfl0KDzT2UEAqu69_f7F2BVPSxVae1cQ/viewform) and check whether your repository appears in that list. + +If your repository is **not** listed, request its addition by posting a message in the [#contributor-experience channel on CNCF Slack](https://cloud-native.slack.com/archives/C06TMJ2R0SK). A maintainer will add your repository to the form's options. Wait until your repository appears in the dropdown before enabling this workflow. + +## How to use + +Add a caller workflow to your repository, for example `.github/workflows/survey-on-merged-pr.yml`: + +```yaml +name: Survey on merged PR + +on: + pull_request_target: # zizmor: ignore[dangerous-triggers] — this workflow only calls the reusable shared workflow; no PR code is checked out or executed. + types: [closed] + branches: [main] + +permissions: {} + +jobs: + survey: + permissions: + pull-requests: write # required by the shared workflow to post the survey comment + uses: open-telemetry/shared-workflows/.github/workflows/survey-on-merged-pr.yml@ +``` + +Pin `` to a commit SHA or release tag in this repository. No inputs, no secrets — the workflow uses the built-in `GITHUB_TOKEN` and posts as `github-actions[bot]`. + +## Required permissions + +The caller's job-level `permissions:` block **must** grant `pull-requests: write`. The shared workflow needs it to post the survey comment via `gh pr comment`. + +A [reusable workflow cannot elevate its own permissions beyond what the caller grants](https://docs.github.com/en/actions/using-workflows/reusing-workflows), so a caller job without `pull-requests: write` will fail with a permission error when the comment step runs. + +The `zizmor: ignore[dangerous-triggers]` inline comment on the `pull_request_target:` line is only relevant if your repo runs [zizmor](https://github.com/zizmorcore/zizmor); it silences the false-positive finding since this caller doesn't check out any PR-controlled code — it just invokes the shared workflow which itself operates entirely through the GitHub API. + +## Behavior notes + +- **Not idempotent per author**: the workflow posts a survey comment on **every** merged PR by a non-member, not just the first. If the same external contributor gets several PRs merged, they receive the survey comment on each one. From 6b0cb91b12ad74f07a5e777547e623db9aa3a34d Mon Sep 17 00:00:00 2001 From: maryliag Date: Thu, 9 Jul 2026 13:10:52 -0400 Subject: [PATCH 2/2] update readme --- survey-on-merged-pr/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/survey-on-merged-pr/README.md b/survey-on-merged-pr/README.md index 0eed9660b..b4202d1cb 100644 --- a/survey-on-merged-pr/README.md +++ b/survey-on-merged-pr/README.md @@ -1,6 +1,6 @@ # Survey on merged PR (non-member) -Reusable GitHub Actions workflow that posts a survey link to a pull request when it is merged, if the author is an external contributor (not an OpenTelemetry org member, not a repo owner or collaborator, and not a bot). Used to gather feedback from new contributors about their OpenTelemetry contribution experience. +Reusable GitHub Actions workflow that posts a survey link to a pull request when it is merged, if the author is a new contributor. Used to gather feedback from new contributors about their OpenTelemetry contribution experience. The survey link automatically includes the caller repository as a query parameter (`entry.1540511742=`), so responses collected in the shared OpenTelemetry Google Form are tagged with the source repo.