ci: only run `publish_snapshot` when not PR (#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 #41877
This commit is contained in:
parent
f3331a8350
commit
ca0fcd6c08
|
@ -66,6 +66,14 @@ var_10: &only_on_master
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
|
# Filter to run a job on all releasable branches.
|
||||||
|
var_11: &only_release_branches
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- /\d+\.\d+\.x/
|
||||||
|
|
||||||
# Executor Definitions
|
# Executor Definitions
|
||||||
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors
|
# https://circleci.com/docs/2.0/reusing-config/#authoring-reusable-executors
|
||||||
# **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.
|
# **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:
|
||||||
publish_snapshot:
|
publish_snapshot:
|
||||||
executor: default-executor
|
executor: default-executor
|
||||||
steps:
|
steps:
|
||||||
# See below - ideally this job should not trigger for non-upstream builds.
|
|
||||||
# But since it does, we have to check this condition.
|
|
||||||
- run:
|
|
||||||
name: Skip this job for Pull Requests and Fork builds
|
|
||||||
# Note: Using `CIRCLE_*` env variables (instead of those defined in `env.sh` so that this
|
|
||||||
# step can be run before `init_environment`.
|
|
||||||
command: >
|
|
||||||
if [[ -n "${CIRCLE_PR_NUMBER}" ]] ||
|
|
||||||
[[ "$CIRCLE_PROJECT_USERNAME" != "angular" ]] ||
|
|
||||||
[[ "$CIRCLE_PROJECT_REPONAME" != "angular" ]]; then
|
|
||||||
circleci step halt
|
|
||||||
fi
|
|
||||||
- custom_attach_workspace
|
- custom_attach_workspace
|
||||||
- init_environment
|
- init_environment
|
||||||
# CircleCI has a config setting to force SSH for all github connections
|
# CircleCI has a config setting to force SSH for all github connections
|
||||||
|
@ -854,10 +850,7 @@ workflows:
|
||||||
requires:
|
requires:
|
||||||
- build-npm-packages
|
- build-npm-packages
|
||||||
- publish_snapshot:
|
- publish_snapshot:
|
||||||
# Note: no filters on this job because we want it to run for all upstream branches
|
<<: *only_release_branches
|
||||||
# We'd really like to filter out pull requests here, but not yet available:
|
|
||||||
# https://discuss.circleci.com/t/workflows-pull-request-filter/14396/4
|
|
||||||
# Instead, the job just exits immediately at the first step.
|
|
||||||
requires:
|
requires:
|
||||||
# Only publish if tests and integration tests pass
|
# Only publish if tests and integration tests pass
|
||||||
- test
|
- test
|
||||||
|
|
|
@ -117,7 +117,6 @@ merge:
|
||||||
requiredStatuses:
|
requiredStatuses:
|
||||||
- "ci/circleci: build"
|
- "ci/circleci: build"
|
||||||
- "ci/circleci: lint"
|
- "ci/circleci: lint"
|
||||||
- "ci/circleci: publish_snapshot"
|
|
||||||
- "ci/angular: size"
|
- "ci/angular: size"
|
||||||
- "cla/google"
|
- "cla/google"
|
||||||
- "google3"
|
- "google3"
|
||||||
|
|
Loading…
Reference in New Issue