From 49b48fcd52fb041865451b7e4ad4a195d733a54a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 16 Sep 2025 13:29:08 +0000 Subject: [PATCH 1/9] Comment workflow (#95) --- .github/workflows/comment_bot.yml | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/comment_bot.yml b/.github/workflows/comment_bot.yml index 85157760d667..b120ee7c1aae 100644 --- a/.github/workflows/comment_bot.yml +++ b/.github/workflows/comment_bot.yml @@ -56,6 +56,44 @@ jobs: --event-name ${{ github.event_name }} \ --event-payload ${{ github.event_path }} + ci: + name: Listen CI! + if: startsWith(github.event.comment.body, '@github-actions ci') && ${{ github.event.issue.pull_request }} + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Checkout Arrow + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + path: arrow + # fetch the tags for version number generation + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 + with: + python-version: 3.12 + - name: Parse comment + id: parse_comment + uses: actions/github-script@v7 + with: + script: | + let body = github.event.comment.body.trim(); + // Match format: @github-actions ci -w workflow_name regex + const match = body.match(/^@github-actions ci\s+-w\s+(\S+)\s+(.+)$/); + if (!match) { + core.setFailed('Comment format invalid. Expected: @github-actions ci -w workflow_name regex'); + } else { + const workflow = match[1]; + const regex = match[2]; + core.setOutput('workflow', workflow); + core.setOutput('regex', regex); + } + - name: Handle GitHub comment event + run: | + echo ${{ steps.parse_comment.outputs.workflow }} + echo ${{ steps.parse_comment.outputs.regex }} + issue_assign: name: "Assign issue" permissions: From 663eef3991fb7432e29f8be8c3215bb95af24f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 16 Sep 2025 15:45:05 +0200 Subject: [PATCH 2/9] Add context.payload.comment --- .github/workflows/comment_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment_bot.yml b/.github/workflows/comment_bot.yml index b120ee7c1aae..db4d51b16a25 100644 --- a/.github/workflows/comment_bot.yml +++ b/.github/workflows/comment_bot.yml @@ -78,7 +78,7 @@ jobs: uses: actions/github-script@v7 with: script: | - let body = github.event.comment.body.trim(); + let body = context.payload.comment.body.trim(); // Match format: @github-actions ci -w workflow_name regex const match = body.match(/^@github-actions ci\s+-w\s+(\S+)\s+(.+)$/); if (!match) { From bd2301e0e326cb367a54540444473c1c95dd1b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 16 Sep 2025 15:56:38 +0200 Subject: [PATCH 3/9] Add new step to run workflow --- .github/workflows/comment_bot.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/comment_bot.yml b/.github/workflows/comment_bot.yml index db4d51b16a25..666281955455 100644 --- a/.github/workflows/comment_bot.yml +++ b/.github/workflows/comment_bot.yml @@ -93,6 +93,15 @@ jobs: run: | echo ${{ steps.parse_comment.outputs.workflow }} echo ${{ steps.parse_comment.outputs.regex }} + - name: Run workflow + id: run_workflow + env: + GH_TOKEN: ${{ github.token }} + run: | + echo "${{ toJson(github.event) }}" + gh workflow run ${{ steps.parse_comment.outputs.workflow }}.yml \ + --ref my-branch \ + -f regex=${{ steps.parse_comment.outputs.regex }} issue_assign: name: "Assign issue" From 2c151832e0e664698cc3209cdbff579c9b85e950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 16 Sep 2025 16:14:29 +0200 Subject: [PATCH 4/9] Extract PR number and branch --- .github/workflows/comment_bot.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/comment_bot.yml b/.github/workflows/comment_bot.yml index 666281955455..390002714224 100644 --- a/.github/workflows/comment_bot.yml +++ b/.github/workflows/comment_bot.yml @@ -98,9 +98,13 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - echo "${{ toJson(github.event) }}" + pr_branch=$(gh pr view ${{ github.event.issue.number }} \ + --jq '.headRefName' \ + --json headRefName \ + --repo ${GITHUB_REPOSITORY}) + echo "pr_branch=${pr_branch}" gh workflow run ${{ steps.parse_comment.outputs.workflow }}.yml \ - --ref my-branch \ + --ref ${pr_branch} \ -f regex=${{ steps.parse_comment.outputs.regex }} issue_assign: From 42730fef318bf88496d2b1d164b89b2358625187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 16 Sep 2025 16:22:17 +0200 Subject: [PATCH 5/9] Add cd arrow --- .github/workflows/comment_bot.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/comment_bot.yml b/.github/workflows/comment_bot.yml index 390002714224..420ed949c390 100644 --- a/.github/workflows/comment_bot.yml +++ b/.github/workflows/comment_bot.yml @@ -103,6 +103,7 @@ jobs: --json headRefName \ --repo ${GITHUB_REPOSITORY}) echo "pr_branch=${pr_branch}" + cd arrow gh workflow run ${{ steps.parse_comment.outputs.workflow }}.yml \ --ref ${pr_branch} \ -f regex=${{ steps.parse_comment.outputs.regex }} From d9647e339c556efa34b0256b7620e845559e0993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 16 Sep 2025 16:30:59 +0200 Subject: [PATCH 6/9] use secrets.GITHUB_TOKEN instead --- .github/workflows/comment_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment_bot.yml b/.github/workflows/comment_bot.yml index 420ed949c390..07e840dc19bf 100644 --- a/.github/workflows/comment_bot.yml +++ b/.github/workflows/comment_bot.yml @@ -96,7 +96,7 @@ jobs: - name: Run workflow id: run_workflow env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | pr_branch=$(gh pr view ${{ github.event.issue.number }} \ --jq '.headRefName' \ From cc9b5d19ed64c232ee236dd56cf32104f9138903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 16 Sep 2025 16:48:34 +0200 Subject: [PATCH 7/9] Add workflow dispatch --- .github/workflows/cpp_extra.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/cpp_extra.yml b/.github/workflows/cpp_extra.yml index 2907ae3bcd18..1ba6fdb8d418 100644 --- a/.github/workflows/cpp_extra.yml +++ b/.github/workflows/cpp_extra.yml @@ -62,6 +62,12 @@ on: - opened - reopened - synchronize + workflow_dispatch: + inputs: + regex: + description: "Regex pattern to run specific jobs" + type: string + required: true schedule: - cron: | 0 0 * * * @@ -113,6 +119,9 @@ jobs: fi fi ;; + workflow_dispatch) + ci_extra=true + ;; esac echo "ci-extra=${ci_extra}" >> "${GITHUB_OUTPUT}" From 5ce9aab3e454093d027c882ce42f0a4210bded49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 16 Sep 2025 17:00:11 +0200 Subject: [PATCH 8/9] Try adding actions write permission --- .github/workflows/comment_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/comment_bot.yml b/.github/workflows/comment_bot.yml index 07e840dc19bf..4fe5527f152c 100644 --- a/.github/workflows/comment_bot.yml +++ b/.github/workflows/comment_bot.yml @@ -61,7 +61,7 @@ jobs: if: startsWith(github.event.comment.body, '@github-actions ci') && ${{ github.event.issue.pull_request }} runs-on: ubuntu-latest permissions: - pull-requests: write + actions: write steps: - name: Checkout Arrow uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 From 41a36db4978d28eeae15a4617828a0b951e2a834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 16 Sep 2025 15:30:08 +0200 Subject: [PATCH 9/9] Test PR --- dev/archery/archery/cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/archery/archery/cli.py b/dev/archery/archery/cli.py index 48ad466977c9..a8735916fd2f 100644 --- a/dev/archery/archery/cli.py +++ b/dev/archery/archery/cli.py @@ -823,6 +823,7 @@ def integration(with_all=False, random_seed=12345, **args): @click.option('--event-payload', '-p', type=click.File('r', encoding='utf8'), default='-', required=True) def trigger_bot(arrow_token, committers_file, event_name, event_payload): + print("Test") from .bot import CommentBot, PullRequestWorkflowBot, actions from ruamel.yaml import YAML