Skip to content

Commit

Permalink
chore(ci): automatically label community PRs with author/community (#…
Browse files Browse the repository at this point in the history
…11604)

When a pull request against the Kong/kong repository is opened,
it should be automatically labeled with author/community if the
account opening the PR is not a member of the Kong organization.
But because of the author's permissions, it is not allowed to
add labels to the PR. So try to use schedule instead of
pull_request to implement this requirement.

KAG-2562
  • Loading branch information
Water-Melon authored Sep 19, 2023
1 parent 03bfc29 commit be0aee6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/label-community-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Label community PRs

on:
schedule:
- cron: '*/30 * * * *'

permissions:
pull-requests: write

jobs:
check_author:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Label Community PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set +e
for id in `gh pr list -S 'draft:false' -s 'open'|awk '{print $1}'`
do
name=`gh pr view $id --json author -q '.author.login'`
gh api orgs/Kong/members --paginate -q '.[].login'|grep -q "^${name}$"
if [ $? -ne 0 ]; then
gh pr edit $id --add-label "author/community"
fi
done

1 comment on commit be0aee6

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:be0aee6b48dc66a67ac57b2b700ea258536127a2
Artifacts available https://github.com/Kong/kong/actions/runs/6236557343

Please sign in to comment.