Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
30 changes: 23 additions & 7 deletions .github/workflows/profile_contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ jobs:
if: github.event.action == 'opened'

permissions:
contents: read
issues: write
pull-requests: write

runs-on: ubuntu-latest

steps:
# Load trust configuration from the trusted base/default branch, never PR head code.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.ref || github.event.repository.default_branch }}
persist-credentials: false
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
- name: Determine target login and issue number
id: meta
Expand All @@ -31,6 +37,7 @@ jobs:
ISSUE_NUMBER: ${{ github.event.issue.number }}
PR_USER_LOGIN: ${{ github.event.pull_request.user.login }}
PR_NUMBER: ${{ github.event.pull_request.number }}

run: |
if [ "$EVENT_NAME" = "issues" ]; then
echo "login=$ISSUE_USER_LOGIN" >> "$GITHUB_OUTPUT"
Expand All @@ -43,11 +50,25 @@ jobs:
fi

- name: Run gh-profiler (=== Expand this to see full profile output ===)
id: profile
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LOGIN: ${{ steps.meta.outputs.login }}
run: |
uvx gh-profiler@latest "$LOGIN" --concise > profiler.txt
if grep -Fq "User $LOGIN is a trusted" profiler.txt; then
echo "trusted=true" >> "$GITHUB_OUTPUT"
echo "Trusted account; skipping profile output and comment."
exit 0
fi
echo "trusted=false" >> "$GITHUB_OUTPUT"
echo
echo "======================= Concise profile ======================="
echo
cat profiler.txt
echo
echo "==============================================================="
echo
echo
echo "======================== Full profile ========================="
echo
Expand All @@ -56,6 +77,7 @@ jobs:
echo "==============================================================="

- name: Comment on issue or PR
if: steps.profile.outputs.trusted != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SERVER_URL: ${{ github.server_url }}
Expand All @@ -67,13 +89,7 @@ jobs:
run: |
{
echo "<!-- gh-profiler:profile-link run-id=$RUN_ID -->"
echo "Profile summary:"
echo
echo '```text'
cat profiler.txt
echo '```'
echo
echo "<a href=\"$SERVER_URL/$REPOSITORY/actions/runs/$RUN_ID/job/$CHECK_RUN_ID\">Full profile</a>"
echo "<a href=\"$SERVER_URL/$REPOSITORY/actions/runs/$RUN_ID/job/$CHECK_RUN_ID\">Contributor profile</a>"
echo
echo "(This comment and the linked profile output will auto-delete when this $ISSUE_PR is closed.)"
} > body.txt
Expand Down
10 changes: 10 additions & 0 deletions gh-profiler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Don't profile these trusted contributors.
# This can be overridden with `--ignore-trusted`.
trusted_contributors = [
"kjaymiller",
"brass75",
]

trusted_bots = [
"dependabot[bot]",
]
Loading