Skip to content

Commit

Permalink
ci: only run publish_snapshot when not PR (angular#41877)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alan-agius4 authored and mhevery committed Apr 29, 2021
1 parent f3331a8 commit ca0fcd6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
25 changes: 9 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ var_10: &only_on_master
only:
- master

# Filter to run a job on all releasable branches.
var_11: &only_release_branches
filters:
branches:
only:
- master
- /\d+\.\d+\.x/

# Executor Definitions
# 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.
Expand Down Expand Up @@ -587,18 +595,6 @@ jobs:
publish_snapshot:
executor: default-executor
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
- init_environment
# CircleCI has a config setting to force SSH for all github connections
Expand Down Expand Up @@ -854,10 +850,7 @@ workflows:
requires:
- build-npm-packages
- publish_snapshot:
# Note: no filters on this job because we want it to run for all upstream 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.
<<: *only_release_branches
requires:
# Only publish if tests and integration tests pass
- test
Expand Down
1 change: 0 additions & 1 deletion .github/angular-robot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ merge:
requiredStatuses:
- "ci/circleci: build"
- "ci/circleci: lint"
- "ci/circleci: publish_snapshot"
- "ci/angular: size"
- "cla/google"
- "google3"
Expand Down

0 comments on commit ca0fcd6

Please sign in to comment.