File tree Expand file tree Collapse file tree 4 files changed +31
-7
lines changed Expand file tree Collapse file tree 4 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -32,11 +32,11 @@ jobs:
32
32
33
33
### Action inputs
34
34
35
- | Name | Description | Required | Default |
36
- |----------------|----------------------------------------------|----------|---------|
37
- | ` github-token` | Token that is used to create comments | ✅ | |
38
- | `check-names` | Comma-separated list of check names to rerun | ✅ | |
39
-
35
+ | Name | Description | Required | Default |
36
+ |----------------- |----------------------------------------------|----------|----------------------------------------- ---------|
37
+ | ` github-token` | Token that is used to create comments | ✅ | |
38
+ | `check-names` | Comma-separated list of check names to rerun | ✅ | |
39
+ | `target-branch` | Branch for which checks should be rerun | ❌ | the head ref of the pull request, default branch |
40
40
# # Permissions
41
41
42
42
Depending on the permissions granted to your token, you may lack some rights.
Original file line number Diff line number Diff line change @@ -12,6 +12,12 @@ inputs:
12
12
github-token :
13
13
description : ' GitHub token'
14
14
required : true
15
+ target-branch :
16
+ description : |
17
+ Branch for which checks should be rerun.
18
+ If not provided, the branch of the pull request that triggered
19
+ the workflow is used
20
+ required : false
15
21
16
22
runs :
17
23
using : ' node20'
Original file line number Diff line number Diff line change @@ -33746,7 +33746,16 @@ async function run() {
33746
33746
try {
33747
33747
const checkNames = core.getInput('check-names').split(', ');
33748
33748
const { owner, repo } = github.context.repo;
33749
- const branch = github.context.payload.pull_request.head.ref;
33749
+ let branch = null;
33750
+
33751
+ if (core.getInput('target-branch')) {
33752
+ branch = core.getInput('target-branch');
33753
+ } else if (github.context.payload.pull_request) {
33754
+ branch = github.context.payload.pull_request.head.ref;
33755
+ } else {
33756
+ const repoInfo = await octokit.rest.repos.get({ owner, repo });
33757
+ branch = repoInfo.data.default_branch; // default branch
33758
+ }
33750
33759
33751
33760
const token = core.getInput('github-token');
33752
33761
const octokit = github.getOctokit(token);
Original file line number Diff line number Diff line change @@ -5,7 +5,16 @@ async function run() {
5
5
try {
6
6
const checkNames = core . getInput ( 'check-names' ) . split ( ', ' ) ;
7
7
const { owner, repo } = github . context . repo ;
8
- const branch = github . context . payload . pull_request . head . ref ;
8
+ let branch = null ;
9
+
10
+ if ( core . getInput ( 'target-branch' ) ) {
11
+ branch = core . getInput ( 'target-branch' ) ;
12
+ } else if ( github . context . payload . pull_request ) {
13
+ branch = github . context . payload . pull_request . head . ref ;
14
+ } else {
15
+ const repoInfo = await octokit . rest . repos . get ( { owner, repo } ) ;
16
+ branch = repoInfo . data . default_branch ; // default branch
17
+ }
9
18
10
19
const token = core . getInput ( 'github-token' ) ;
11
20
const octokit = github . getOctokit ( token ) ;
You can’t perform that action at this time.
0 commit comments