-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
config.yml
63 lines (51 loc) · 2.13 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
version: 2.1
setup: true
orbs:
continuation: circleci/[email protected]
jobs:
verify-ci-should-run:
resource_class: small
docker:
- image: cimg/node:current
steps:
- run:
name: Verify CI should run
command: |
# run CI when manually triggers via CircleCi Dashboard
if [ <<pipeline.trigger_source>> == 'api' ]; then
echo "Always run CI when manually triggered from the UI."
exit 0
fi
if [[ "$CIRCLE_BRANCH" == "develop" || "$CIRCLE_BRANCH" == "release/"* ]]; then
echo "Always run CI for develop and for release candidate branches."
exit 0
fi
LAST_COMMIT_MESSAGE=$(curl --silent "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/commits/${CIRCLE_BRANCH}" | jq '.commit.message')
if [[ "$LAST_COMMIT_MESSAGE" =~ "run ci" ]]; then
echo "Always run CI when the commit message includes 'run ci'."
exit 0
fi
cancel_build () {
echo "Canceling the CI build..."
circleci-agent step halt
}
TRIGGER_INSTRUCTIONS="to trigger CI , include 'run ci' in the commit message or click the 'Trigger Pipeline' button in the CircleCI UI."
if [ ! -z "${CIRCLE_PULL_REQUEST##*/}" ]; then
DRAFT=$(curl --silent "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${CIRCLE_PULL_REQUEST##*/}" | jq '.draft')
if [[ "${DRAFT}" == true ]]; then
echo "Skipping CI; PR is in draft - $TRIGGER_INSTRUCTIONS"
cancel_build
fi
echo "Always run CI for PR that is ready for review."
exit 0
fi
echo "Skipping CI; branch in progress - $TRIGGER_INSTRUCTIONS"
cancel_build
- checkout
- continuation/continue:
configuration_path: .circleci/workflows.yml
workflows:
# the setup-workflow workflow is always triggered.
setup-workflow:
jobs:
- verify-ci-should-run