Skip to content
Merged
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
29 changes: 29 additions & 0 deletions .github/workflows/star_before_merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check if PR author starred the repo

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
check-star:
runs-on: ubuntu-latest
steps:
- name: Check if user starred repo
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: ${{ github.actor }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
echo "Checking if $USER starred $OWNER/$REPO"
curl -s -H "Authorization: token $GH_TOKEN" \
https://api.github.com/repos/$OWNER/$REPO/stargazers?per_page=100 \
| jq -r '.[].login' > stargazers.txt

if grep -q "^$USER$" stargazers.txt; then
echo "User $USER has starred the repo 🎉"
else
echo "::error::User $USER has not starred the repo. Please star it before merging."
exit 1
fi