From c787ac2d2ac6c07c43fdd6a58e48e6193ece2533 Mon Sep 17 00:00:00 2001 From: Steve Yonkeu <71908316+yokwejuste@users.noreply.github.com> Date: Fri, 3 Oct 2025 07:06:22 +0100 Subject: [PATCH] Add workflow to check if PR author starred repo This workflow checks if the pull request author has starred the repository before allowing the merge. --- .github/workflows/add_star_before_merge.yml | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/add_star_before_merge.yml diff --git a/.github/workflows/add_star_before_merge.yml b/.github/workflows/add_star_before_merge.yml new file mode 100644 index 0000000..04233fe --- /dev/null +++ b/.github/workflows/add_star_before_merge.yml @@ -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 +