Skip to content

Commit 1831f66

Browse files
committed
run workflow manually
1 parent 5828734 commit 1831f66

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed

.github/workflows/style-bot-action.yml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
type: string
99
description: "Which style command to run (options: 'default' (make style && make quality), 'quality_only', 'style_only')"
1010
default: "default"
11+
pr_number:
12+
required: false
13+
type: number
14+
description: "Pull Request number to process (only used when running manually)"
1115
python_quality_dependencies:
1216
required: true
1317
type: string
@@ -25,8 +29,10 @@ on:
2529
jobs:
2630
check-permissions:
2731
if: >
28-
contains(github.event.comment.body, '@bot /style') &&
29-
github.event.issue.pull_request != null
32+
(github.event_name == 'issue_comment' &&
33+
contains(github.event.comment.body, '@bot /style') &&
34+
github.event.issue.pull_request != null) ||
35+
github.event_name == 'workflow_dispatch'
3036
runs-on: ubuntu-latest
3137
outputs:
3238
is_authorized: ${{ steps.check_user_permission.outputs.has_permission }}
@@ -36,7 +42,14 @@ jobs:
3642
uses: actions/github-script@v6
3743
with:
3844
script: |
39-
const comment_user = context.payload.comment.user.login;
45+
let comment_user;
46+
if (context.eventName === 'workflow_dispatch') {
47+
comment_user = context.actor;
48+
console.log('Workflow triggered manually by:', comment_user);
49+
} else {
50+
comment_user = context.payload.comment.user.login;
51+
console.log('Workflow triggered by comment from:', comment_user);
52+
}
4053
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
4154
owner: context.repo.owner,
4255
repo: context.repo.repo,
@@ -56,18 +69,29 @@ jobs:
5669
uses: actions/github-script@v6
5770
with:
5871
script: |
59-
const prNumber = context.payload.issue.number;
72+
const prNumber = context.eventName === 'workflow_dispatch'
73+
? context.payload.inputs.pr_number
74+
: context.payload.issue.number;
75+
76+
// Get PR details
6077
const { data: pr } = await github.rest.pulls.get({
6178
owner: context.repo.owner,
6279
repo: context.repo.repo,
6380
pull_number: prNumber
6481
});
6582
66-
// We capture both the branch ref and the "full_name" of the head repo
67-
// so that we can check out the correct repository & branch (including forks).
68-
core.setOutput("prNumber", prNumber);
69-
core.setOutput("headRef", pr.head.ref);
70-
core.setOutput("headRepoFullName", pr.head.repo.full_name);
83+
// Set outputs for use in subsequent steps
84+
core.setOutput('headRepoFullName', pr.head.repo.full_name);
85+
core.setOutput('headRef', pr.head.ref);
86+
core.setOutput('baseRef', pr.base.ref);
87+
core.setOutput('prNumber', prNumber);
88+
89+
console.log('PR Details:', {
90+
number: prNumber,
91+
headRepo: pr.head.repo.full_name,
92+
headRef: pr.head.ref,
93+
baseRef: pr.base.ref
94+
});
7195
7296
- name: Check out PR branch
7397
uses: actions/checkout@v3
@@ -96,7 +120,9 @@ jobs:
96120
uses: actions/github-script@v6
97121
with:
98122
script: |
99-
const prNumber = context.payload.issue.number;
123+
const prNumber = context.eventName === 'workflow_dispatch'
124+
? context.payload.inputs.pr_number
125+
: context.payload.issue.number;
100126
const { data: pr } = await github.rest.pulls.listFiles({
101127
owner: context.repo.owner,
102128
repo: context.repo.repo,

.github/workflows/style-bot.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ name: Style Bot
33
on:
44
issue_comment:
55
types: [created]
6-
6+
workflow_dispatch:
7+
inputs:
8+
pr_number:
9+
description: 'Pull Request number to run style checks on'
10+
required: false
11+
type: number
12+
713
permissions:
814
contents: write
915
pull-requests: write
@@ -14,5 +20,6 @@ jobs:
1420
with:
1521
python_quality_dependencies: "[quality]"
1622
style_command_type: "style_only"
23+
pr_number: ${{ fromJSON(inputs.pr_number) }}
1724
secrets:
1825
bot_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)