1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ name : PR commands
19
+
20
+ on :
21
+ issue_comment :
22
+ types : [created]
23
+
24
+ permissions :
25
+ contents : read
26
+ pull-requests : write
27
+ actions : write
28
+ checks : write
29
+
30
+ jobs :
31
+ # Starts the extended_tests on a PR branch when someone leaves a `Run extended tests` comment
32
+ run_extended_tests :
33
+ runs-on : ubuntu-latest
34
+ if : ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, 'Run extended tests') }}
35
+ steps :
36
+ - name : Dispatch extended tests for a PR branch with comment
37
+ uses : actions/github-script@v7
38
+ with :
39
+ github-token : ${{ secrets.GITHUB_TOKEN }}
40
+ script : |
41
+ // Get PR details to fetch the branch name
42
+ const { data: pullRequest } = await github.rest.pulls.get({
43
+ owner: context.repo.owner,
44
+ repo: context.repo.repo,
45
+ pull_number: context.payload.issue.number
46
+ });
47
+
48
+ // Extract the branch name
49
+ const branchName = pullRequest.head.ref;
50
+ const headSha = pullRequest.head.sha;
51
+ const workflowRunsUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions?query=workflow%3A%22Datafusion+extended+tests%22+branch%3A${branchName}`;
52
+
53
+ // Create a check run that links to the Actions tab so the run will be visible in GitHub UI
54
+ const check = await github.rest.checks.create({
55
+ owner: context.repo.owner,
56
+ repo: context.repo.repo,
57
+ name: 'Extended Tests',
58
+ head_sha: headSha,
59
+ status: 'in_progress',
60
+ output: {
61
+ title: 'Extended Tests Running',
62
+ summary: `Extended tests have been triggered for this PR.\n\n[View workflow runs](${workflowRunsUrl})`
63
+ },
64
+ details_url: workflowRunsUrl
65
+ });
66
+
67
+ // Dispatch the workflow with the PR branch name
68
+ await github.rest.actions.createWorkflowDispatch({
69
+ owner: context.repo.owner,
70
+ repo: context.repo.repo,
71
+ workflow_id: 'extended.yml',
72
+ ref: branchName,
73
+ inputs: {
74
+ pr_number: context.payload.issue.number.toString(),
75
+ check_run_id: check.data.id.toString(),
76
+ pr_head_sha: headSha
77
+ }
78
+ });
79
+
80
+ - name : Add reaction to comment
81
+ uses : actions/github-script@v7
82
+ with :
83
+ script : |
84
+ await github.rest.reactions.createForIssueComment({
85
+ owner: context.repo.owner,
86
+ repo: context.repo.repo,
87
+ comment_id: context.payload.comment.id,
88
+ content: 'rocket'
89
+ });
0 commit comments