Skip to content

Commit ca0fcd6

Browse files
alan-agius4mhevery
authored andcommitted
ci: only run publish_snapshot when not PR (angular#41877)
Currently, the non forked PRs such as Renovate will run `publish_snapshot` because `CIRCLE_PR_NUMBER` is not defined for PRs which are opened from non forked repos. Instead we add a filter to only run `publish_snapshot` on releasable branches. Example of run were the mentioned variable is not defined https://app.circleci.com/pipelines/github/angular/angular/32093/workflows/7c8c4cfc-e6f6-44fc-a6dc-a82a6ac862db/jobs/976611 PR Close angular#41877
1 parent f3331a8 commit ca0fcd6

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

.circleci/config.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ var_10: &only_on_master
6666
only:
6767
- master
6868

69+
# Filter to run a job on all releasable branches.
70+
var_11: &only_release_branches
71+
filters:
72+
branches:
73+
only:
74+
- master
75+
- /\d+\.\d+\.x/
76+
6977
# Executor Definitions
7078
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors
7179
# **NOTE 1**: Pin to exact images using an ID (SHA). See https://circleci.com/docs/2.0/circleci-images/#using-a-docker-image-id-to-pin-an-image-to-a-fixed-version.
@@ -587,18 +595,6 @@ jobs:
587595
publish_snapshot:
588596
executor: default-executor
589597
steps:
590-
# See below - ideally this job should not trigger for non-upstream builds.
591-
# But since it does, we have to check this condition.
592-
- run:
593-
name: Skip this job for Pull Requests and Fork builds
594-
# Note: Using `CIRCLE_*` env variables (instead of those defined in `env.sh` so that this
595-
# step can be run before `init_environment`.
596-
command: >
597-
if [[ -n "${CIRCLE_PR_NUMBER}" ]] ||
598-
[[ "$CIRCLE_PROJECT_USERNAME" != "angular" ]] ||
599-
[[ "$CIRCLE_PROJECT_REPONAME" != "angular" ]]; then
600-
circleci step halt
601-
fi
602598
- custom_attach_workspace
603599
- init_environment
604600
# CircleCI has a config setting to force SSH for all github connections
@@ -854,10 +850,7 @@ workflows:
854850
requires:
855851
- build-npm-packages
856852
- publish_snapshot:
857-
# Note: no filters on this job because we want it to run for all upstream branches
858-
# We'd really like to filter out pull requests here, but not yet available:
859-
# https://discuss.circleci.com/t/workflows-pull-request-filter/14396/4
860-
# Instead, the job just exits immediately at the first step.
853+
<<: *only_release_branches
861854
requires:
862855
# Only publish if tests and integration tests pass
863856
- test

.github/angular-robot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ merge:
117117
requiredStatuses:
118118
- "ci/circleci: build"
119119
- "ci/circleci: lint"
120-
- "ci/circleci: publish_snapshot"
121120
- "ci/angular: size"
122121
- "cla/google"
123122
- "google3"

0 commit comments

Comments
 (0)