Skip to content

Commit bebbba0

Browse files
committed
Update gh-profiler workflow to ignore trusted users
1 parent b04478f commit bebbba0

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

‎.github/workflows/profile_contributors.yml‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@ jobs:
1616
if: github.event.action == 'opened'
1717

1818
permissions:
19+
contents: read
1920
issues: write
2021
pull-requests: write
2122

2223
runs-on: ubuntu-latest
2324

2425
steps:
26+
# Load trust configuration from the trusted base/default branch, never PR head code.
27+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
28+
with:
29+
ref: ${{ github.event.pull_request.base.ref || github.event.repository.default_branch }}
30+
persist-credentials: false
2531
- uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
2632
- name: Determine target login and issue number
2733
id: meta
@@ -31,6 +37,7 @@ jobs:
3137
ISSUE_NUMBER: ${{ github.event.issue.number }}
3238
PR_USER_LOGIN: ${{ github.event.pull_request.user.login }}
3339
PR_NUMBER: ${{ github.event.pull_request.number }}
40+
3441
run: |
3542
if [ "$EVENT_NAME" = "issues" ]; then
3643
echo "login=$ISSUE_USER_LOGIN" >> "$GITHUB_OUTPUT"
@@ -43,11 +50,25 @@ jobs:
4350
fi
4451
4552
- name: Run gh-profiler (=== Expand this to see full profile output ===)
53+
id: profile
4654
env:
4755
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4856
LOGIN: ${{ steps.meta.outputs.login }}
4957
run: |
5058
uvx gh-profiler@latest "$LOGIN" --concise > profiler.txt
59+
if grep -Fq "User $LOGIN is a trusted" profiler.txt; then
60+
echo "trusted=true" >> "$GITHUB_OUTPUT"
61+
echo "Trusted account; skipping profile output and comment."
62+
exit 0
63+
fi
64+
echo "trusted=false" >> "$GITHUB_OUTPUT"
65+
echo
66+
echo "======================= Concise profile ======================="
67+
echo
68+
cat profiler.txt
69+
echo
70+
echo "==============================================================="
71+
echo
5172
echo
5273
echo "======================== Full profile ========================="
5374
echo
@@ -56,6 +77,7 @@ jobs:
5677
echo "==============================================================="
5778
5879
- name: Comment on issue or PR
80+
if: steps.profile.outputs.trusted != 'true'
5981
env:
6082
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6183
SERVER_URL: ${{ github.server_url }}
@@ -67,13 +89,7 @@ jobs:
6789
run: |
6890
{
6991
echo "<!-- gh-profiler:profile-link run-id=$RUN_ID -->"
70-
echo "Profile summary:"
71-
echo
72-
echo '```text'
73-
cat profiler.txt
74-
echo '```'
75-
echo
76-
echo "<a href=\"$SERVER_URL/$REPOSITORY/actions/runs/$RUN_ID/job/$CHECK_RUN_ID\">Full profile</a>"
92+
echo "<a href=\"$SERVER_URL/$REPOSITORY/actions/runs/$RUN_ID/job/$CHECK_RUN_ID\">Contributor profile</a>"
7793
echo
7894
echo "(This comment and the linked profile output will auto-delete when this $ISSUE_PR is closed.)"
7995
} > body.txt

‎gh-profiler.toml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Don't profile these trusted contributors.
2+
# This can be overridden with `--ignore-trusted`.
3+
trusted_contributors = [
4+
"kjaymiller",
5+
"brass75",
6+
]
7+
8+
trusted_bots = [
9+
"dependabot[bot]",
10+
]

0 commit comments

Comments
 (0)