Created
May 17, 2024 09:55
-
-
Save encima/344190bd1aec4db8c281c6be4d854b74 to your computer and use it in GitHub Desktop.
Auto Label Issues and PRs - Github Action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Label PRs | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
check-external: | |
runs-on: ubuntu-latest | |
outputs: | |
result: ${{ steps.is-member.outputs.result }} | |
steps: | |
- name: Get deps | |
run: | | |
sudo apt-get update && sudo apt-get install -y jq | |
- name: Get org members | |
id: is-member | |
env: | |
GH_ORG: supabase | |
GH_USER: ${{ github.event.pull_request.user.login }} | |
GH_TOKEN: ${{ secrets.GH_ORG_MEMBERSHIP_PAT }} | |
run: | | |
gh api /orgs/supabase/members/$GH_USER | |
- if: failure() | |
name: is-member | |
run: | | |
echo "User is not a member of Supabase org" | |
echo "result=false" >> $GH_OUTPUT | |
- if: success() | |
run: | | |
echo "User is a member of Supabase org, not applying labels" | |
- name: Label contributor | |
id: label-contributor | |
if: ${{ steps.is-member.outputs.result == 'false' }} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
USERNAME: ${{ github.event.pull_request.user.login }} | |
GH_REPO: ${{ github.repository }} | |
NUMBER: ${{ github.event.pull_request.number }} | |
LABELS: contributor | |
run: | | |
gh pr edit $NUMBER --add-label $LABELS | |
- uses: actions/checkout@v4 | |
if: ${{ steps.is-member.outputs.result == 'false' }} | |
- name: Label PR | |
if: ${{ steps.is-member.outputs.result == 'false' }} | |
uses: actions/labeler@v5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment