Skip to content

Commit d22ef19

Browse files
authored
Improve performance of pr-merge job (#65)
* feat: add repo parameter to pr-merge job fix: performance improvement of pr-merge job * fix: empty check of $repo When the $branch is an URL of pull request, clone is still not necessary even if $repo is empty.
1 parent f64c929 commit d22ef19

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/jobs/pr-merge.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ parameters:
2222
description: >
2323
Specify the hostname of the GitHub instance to authenticate with.
2424
Set this to connect to your GitHub Enterprise instance.
25+
repo:
26+
type: string
27+
default: "$CIRCLE_REPOSITORY_URL"
28+
description: Enter either the name of the repository or the full repository URL. Will default to the current project.
2529
token:
2630
type: env_var_name
2731
default: "GITHUB_TOKEN"
@@ -36,12 +40,12 @@ parameters:
3640
steps:
3741
- install:
3842
version: <<parameters.version>>
39-
- clone
4043
- run:
4144
name: "Merging PR to target branch"
4245
environment:
4346
ORB_EVAL_ADDITIONAL_ARGS: <<parameters.additional_args>>
4447
ORB_EVAL_BRANCH: <<parameters.branch>>
4548
ORB_EVAL_HOSTNAME: <<parameters.hostname>>
49+
ORB_EVAL_REPO: <<parameters.repo>>
4650
ORB_ENV_TOKEN: <<parameters.token>>
4751
command: <<include(scripts/pr-merge.sh)>>

src/scripts/pr-merge.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
branch="$(eval printf '%s' "$ORB_EVAL_BRANCH")"
33
additional_args="$(eval printf '%s\\n' "$ORB_EVAL_ADDITIONAL_ARGS")"
44
hostname="$(eval printf '%s' "$ORB_EVAL_HOSTNAME")"
5+
repo="$(eval printf '%s' "$ORB_EVAL_REPO")"
56
token="${!ORB_ENV_TOKEN}"
67

78
[ -z "$token" ] && {
@@ -10,10 +11,11 @@ token="${!ORB_ENV_TOKEN}"
1011
}
1112
printf '%s\n' "export GITHUB_TOKEN=$token" >>"$BASH_ENV"
1213
[ -n "$hostname" ] && printf '%s\n' "export GITHUB_HOSTNAME=$hostname" >>"$BASH_ENV"
14+
[ -n "$repo" ] && repo="-R $repo"
1315

1416
set -x
1517
# shellcheck disable=SC2086
1618
gh pr merge \
17-
$branch --repo "$(git config --get remote.origin.url)" \
19+
$branch $repo \
1820
$additional_args
1921
set +x

0 commit comments

Comments
 (0)