Skip to content

Commit 3ea0383

Browse files
alan-agius4clydin
authored andcommitted
ci: extract rebase PR login into a common command
This reduces code duplicatation
1 parent cebcf56 commit 3ea0383

File tree

1 file changed

+18
-24
lines changed

1 file changed

+18
-24
lines changed

.circleci/dynamic_config.yml

+18-24
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ commands:
8787
name: Initialize Environment
8888
command: ./.circleci/env.sh
8989

90+
rebase_pr:
91+
steps:
92+
- run:
93+
name: Rebase PR on target branch
94+
shell: bash
95+
command: >
96+
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
97+
# User is required for rebase.
98+
git config user.name "angular-ci"
99+
git config user.email "angular-ci"
100+
# Rebase PR on top of target branch.
101+
node tools/rebase-pr.js angular/angular-cli ${CIRCLE_PR_NUMBER}
102+
else
103+
echo "This build is not over a PR, nothing to do."
104+
fi
105+
90106
custom_attach_workspace:
91107
description: Attach workspace at a predefined location
92108
steps:
@@ -145,18 +161,7 @@ jobs:
145161
resource_class: medium
146162
steps:
147163
- checkout
148-
- run:
149-
name: Rebase PR on target branch
150-
command: >
151-
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
152-
# User is required for rebase.
153-
git config user.name "angular-ci"
154-
git config user.email "angular-ci"
155-
# Rebase PR on top of target branch.
156-
node tools/rebase-pr.js angular/angular-cli ${CIRCLE_PR_NUMBER}
157-
else
158-
echo "This build is not over a PR, nothing to do."
159-
fi
164+
- rebase_pr
160165
- initialize_env
161166
- restore_cache:
162167
keys:
@@ -309,18 +314,7 @@ jobs:
309314
parallelism: 8
310315
steps:
311316
- checkout
312-
- run:
313-
name: Rebase PR on target branch
314-
command: |
315-
if (Test-Path env:CIRCLE_PR_NUMBER) {
316-
# User is required for rebase.
317-
git config user.name "angular-ci"
318-
git config user.email "angular-ci"
319-
# Rebase PR on top of target branch.
320-
node tools/rebase-pr.js angular/angular-cli $env:CIRCLE_PR_NUMBER
321-
} else {
322-
echo "This build is not over a PR, nothing to do."
323-
}
317+
- rebase_pr
324318
- setup_windows
325319
- restore_cache:
326320
keys:

0 commit comments

Comments
 (0)