From d7103632e3be19bcf7078dbbef768cc8d60bc75d Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sat, 29 Aug 2026 19:30:15 +0300 Subject: [PATCH] Profile contributors --- .github/workflows/profile-issue-authors.yml | 101 ++++++++++++++++++++ .github/workflows/profile-pr-authors.yml | 39 ++++++++ 2 files changed, 140 insertions(+) create mode 100644 .github/workflows/profile-issue-authors.yml create mode 100644 .github/workflows/profile-pr-authors.yml diff --git a/.github/workflows/profile-issue-authors.yml b/.github/workflows/profile-issue-authors.yml new file mode 100644 index 00000000..cca7300c --- /dev/null +++ b/.github/workflows/profile-issue-authors.yml @@ -0,0 +1,101 @@ +# Run gh-profiler against the author of each new issue. +# Delete the profile output when the issue is closed. +# PR authors are profiled by the unprivileged profile-pr-authors.yml instead, +# so no dangerous trigger is needed for PRs from forks. + +name: Profile issue authors + +on: + issues: + types: [opened, closed] + +jobs: + profile-author: + if: github.event.action == 'opened' + + permissions: + issues: write + + runs-on: ubuntu-latest + + steps: + - uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 + with: + enable-cache: false + ignore-empty-workdir: true + + - name: Run gh-profiler (=== Expand this to see full profile output ===) + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LOGIN: ${{ github.event.issue.user.login }} + run: | + uvx gh-profiler@latest "$LOGIN" --concise > profiler.txt + echo + echo "======================== Full profile =========================" + echo + uvx gh-profiler@latest "$LOGIN" + echo + echo "===============================================================" + + - name: Comment on issue + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SERVER_URL: ${{ github.server_url }} + REPOSITORY: ${{ github.repository }} + RUN_ID: ${{ github.run_id }} + CHECK_RUN_ID: ${{ job.check_run_id }} + NUMBER: ${{ github.event.issue.number }} + run: | + { + echo "" + echo "Profile summary:" + echo + echo '```text' + cat profiler.txt + echo '```' + echo + echo "Full profile" + echo + echo "(This comment and the linked profile output will auto-delete when this issue is closed.)" + } > body.txt + + jq -Rs '{body: .}' body.txt > payload.json + + gh api \ + "repos/$REPOSITORY/issues/$NUMBER/comments" \ + --input payload.json + + delete-profile: + if: github.event.action == 'closed' + + permissions: + actions: write + issues: write + + runs-on: ubuntu-latest + + steps: + - name: Delete profile comment + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPOSITORY: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} + run: | + gh api --paginate \ + "repos/$REPOSITORY/issues/$NUMBER/comments" \ + --jq ' + .[] + | select(.user.login == "github-actions[bot]") + | select(.body | startswith("