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
31 changes: 31 additions & 0 deletions .github/workflows/smallbot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: SmallBot
on:
issue_comment:
types: [created]
jobs:
bot:
if: startsWith(github.event.comment.body, 'smallbot! ')
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Match command
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENT: ${{ github.event.comment.body }}
USER: ${{ github.event.comment.user.login }}
ISSUE: ${{ github.event.issue.number }}
run: |
COMMAND="${COMMENT#smallbot! }"
if [ "$COMMAND" = "assign" ]; then
COUNT=$(gh issue view "$ISSUE" --json assignees --jq '.assignees | length')
if [ "$COUNT" -eq 0 ]; then
gh issue edit "$ISSUE" --add-assignee "$USER"
fi
fi
if [ "$COMMAND" = "unassign" ]; then
ASSIGNED=$(gh issue view "$ISSUE" --json assignees --jq "[.assignees[].login] | index(\"$USER\")")
if [ "$ASSIGNED" != "null" ]; then
gh issue edit "$ISSUE" --remove-assignee "$USER"
fi
fi
Loading