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
2529jobs :
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 }}
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
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,
0 commit comments