Skip to content

Commit

Permalink
Merge pull request #13 from kerthcet/feat/outputs
Browse files Browse the repository at this point in the history
Add workflows and owners
  • Loading branch information
InftyAI-Agent authored Jun 23, 2024
2 parents 9df675a + 084b811 commit a774b18
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/kube-actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: PR Actions

on:
issue_comment:
types: [created]
pull_request:
types: [labeled]

jobs:
handle-comments:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install yq
run: pip install yq

- name: Handle PR Comments
id: handle_comments
run: |
COMMENT_BODY=$(jq -r '.comment.body' $GITHUB_EVENT_PATH)
PR_NUMBER=$(jq -r '.pull_request.number' $GITHUB_EVENT_PATH)
COMMENT_USER=$(jq -r '.comment.user.login' $GITHUB_EVENT_PATH)
OWNER_FILE=$(cat OWNER)
if [[ "$COMMENT_BODY" == "/lgtm" ]]; then
gh pr edit $PR_NUMBER --add-label lgtm
elif [[ "$COMMENT_BODY" == "/approve" ]]; then
APPROVERS=$(echo "$OWNER_FILE" | yq e '.approvers[]' -)
if echo "$APPROVERS" | grep -q "$COMMENT_USER"; then
gh pr edit $PR_NUMBER --add-label approved
else
echo "User $COMMENT_USER is not authorized to approve"
exit 1
fi
elif [[ "$COMMENT_BODY" == "/kind feature" ]]; then
gh pr edit $PR_NUMBER --add-label feature
elif [[ "$COMMENT_BODY" == "/kind bug" ]]; then
gh pr edit $PR_NUMBER --add-label bug
elif [[ "$COMMENT_BODY" == "/kind cleanup" ]]; then
gh pr edit $PR_NUMBER --add-label cleanup
else
echo "$COMMENT_BODY is not supported"
exit 1
fi
- name: Merge PR if lgtmed and approved
env:
GITHUB_TOKEN: ${{ secrets.AGENT_TOKEN }}
run: |
PR_NUMBER=$(jq -r '.pull_request.number' $GITHUB_EVENT_PATH)
LABELS=$(gh pr view $PR_NUMBER --json labels --jq '.labels[].name')
if [[ "$LABELS" == *"lgtm"* && "$LABELS" == *"approved"* ]]; then
gh pr merge $PR_NUMBER --merge
fi
5 changes: 5 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
approvers:
- kerthcet

reviewers:
- kerthcet

0 comments on commit a774b18

Please sign in to comment.