Skip to content

Commit

Permalink
Initial GitHub Workflow triggering archery bot
Browse files Browse the repository at this point in the history
  • Loading branch information
raulcd committed Feb 10, 2023
1 parent 0074a66 commit 27313fc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/pr_bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: pr-bot
on:
pull_request:
types:
- opened
- converted_to_draft
- ready_for_review
pull_request_review:
types:
- submitted
push:

jobs:
run-pr-bot:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout Arrow
uses: actions/checkout@v3
with:
path: arrow
# fetch the tags for version number generation
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Archery and Crossbow dependencies
run: pip install -e arrow/dev/archery[bot]
- name: Handle PR workflow event
env:
ARROW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROSSBOW_GITHUB_TOKEN: ${{ secrets.CROSSBOW_GITHUB_TOKEN }}
run: |
archery trigger-bot \
--event-name ${{ github.event_name }} \
--event-payload ${{ github.event_path }}
14 changes: 11 additions & 3 deletions dev/archery/archery/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,18 @@ def integration(with_all=False, random_seed=12345, **args):
def trigger_bot(event_name, event_payload, arrow_token):
from .bot import CommentBot, actions

event_payload = json.loads(event_payload.read())
class PullRequestWorkflowBot:
def handle(self, event_name, event_payload):
print(f"PullRequestWorkflowBot handle: {event_name} - {event_payload}")


bot = CommentBot(name='github-actions', handler=actions, token=arrow_token)
bot.handle(event_name, event_payload)
event_payload = json.loads(event_payload.read())
if 'comment' in event_name:
bot = CommentBot(name='github-actions', handler=actions, token=arrow_token)
bot.handle(event_name, event_payload)
else:
bot = PullRequestWorkflowBot()
bot.handle(event_name, event_payload)


@archery.group("linking")
Expand Down

0 comments on commit 27313fc

Please sign in to comment.