-
-
Save jeffomatic/0c5fb761627f2e5636229b0d8da5a9ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2.1 | |
executors: | |
executor-linux-small: | |
docker: | |
- image: cimg/base:2020.01 | |
resource_class: small | |
commands: | |
always-fail: | |
steps: | |
- run: | |
shell: bash | |
command: exit 1 | |
jobs: | |
send-workflow-start-callback: | |
executor: executor-linux-small | |
steps: | |
- run: | |
shell: bash | |
command: | | |
set -euo pipefail | |
payload=$( | |
jq -n \ | |
--arg id "$CIRCLE_WORKFLOW_ID" \ | |
'{type: "workflow-started", workflow: {id: $id}}' | |
) | |
curl -s -f -X POST \ | |
-H 'Content-type: application/json' \ | |
--data "$payload" \ | |
"$DESKTOP_CI_BOT_CALLBACK_URL" | |
job-hello-world: | |
executor: executor-linux-small | |
steps: | |
- run: echo "hello world" | |
job-old-joe: | |
executor: executor-linux-small | |
steps: | |
- run: echo "old joe" | |
job-old-joe-failure: | |
executor: executor-linux-small | |
steps: | |
- always-fail | |
job-failure: | |
executor: executor-linux-small | |
steps: | |
- always-fail | |
workflows: | |
run-ci: | |
when: | |
not: | |
equal: [ main, << pipeline.git.branch >> ] | |
jobs: | |
- send-workflow-start-callback | |
- job-hello-world | |
run-post-merge: | |
when: | |
or: | |
- equal: [ << pipeline.git.branch >>, main ] | |
- equal: [ << pipeline.git.branch >>, main-circleci-test ] | |
jobs: | |
- send-workflow-start-callback | |
- job-hello-world | |
nightly: | |
when: | |
equal: [ << pipeline.git.tag >>, nightly ] | |
jobs: | |
- send-workflow-start-callback | |
- job-hello-world | |
run-release-build: | |
when: | |
matches: | |
pattern: "^(ci-test-)?\\d+\\.\\d+\\.\\d+(-\\w+)*$" | |
value: << pipeline.git.tag >> | |
jobs: | |
- send-workflow-start-callback | |
- job-hello-world | |
- job-old-joe | |
- job-old-joe-failure | |
# - job-failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2.1 | |
anchors: | |
# To implement tag-triggered workflows: | |
# | |
# 1. Add a `when:` property to the top level of the workflow object, | |
# specifying which tag or tag patterns should trigger the workflow. See | |
# nightly and run-release-build for examples. | |
# | |
# 2. Add the following anchor to every job in the workflow. Unfortunately, | |
# CircleCI jobs ignore tag triggers by default, and there is no | |
# workflow-level setting that lets you enable tag triggers. | |
filters-tag-triggered-workflow-job: &filters-tag-triggered-workflow-job | |
filters: | |
tags: | |
only: /.*/ | |
executors: | |
executor-linux-small: | |
docker: | |
- image: cimg/base:2020.01 | |
resource_class: small | |
commands: | |
always-fail: | |
steps: | |
- run: | |
shell: bash | |
command: exit 1 | |
jobs: | |
send-workflow-start-callback: | |
executor: executor-linux-small | |
steps: | |
- run: | |
shell: bash | |
command: | | |
set -euo pipefail | |
payload=$( | |
jq -n \ | |
--arg id "$CIRCLE_WORKFLOW_ID" \ | |
'{type: "workflow-started", workflow: {id: $id}}' | |
) | |
curl -s -f -X POST \ | |
-H 'Content-type: application/json' \ | |
--data "$payload" \ | |
"$DESKTOP_CI_BOT_CALLBACK_URL" | |
job-hello-world: | |
executor: executor-linux-small | |
steps: | |
- run: echo "hello world" | |
job-old-joe: | |
executor: executor-linux-small | |
steps: | |
- run: echo "old joe" | |
job-old-joe-failure: | |
executor: executor-linux-small | |
steps: | |
- always-fail | |
job-failure: | |
executor: executor-linux-small | |
steps: | |
- always-fail | |
workflows: | |
run-ci: | |
when: | |
not: | |
equal: [ main, << pipeline.git.branch >> ] | |
jobs: | |
- send-workflow-start-callback | |
- job-hello-world | |
run-post-merge: | |
when: | |
or: | |
- equal: [ << pipeline.git.branch >>, main ] | |
- equal: [ << pipeline.git.branch >>, main-circleci-test ] | |
jobs: | |
- send-workflow-start-callback | |
- job-hello-world | |
nightly: | |
when: | |
equal: [ << pipeline.git.tag >>, nightly ] | |
jobs: | |
- send-workflow-start-callback: | |
<<: *filters-tag-triggered-workflow-job | |
- job-hello-world: | |
<<: *filters-tag-triggered-workflow-job | |
run-release-build: | |
when: | |
matches: | |
pattern: "^(ci-test-)?\\d+\\.\\d+\\.\\d+(-\\w+)*$" | |
value: << pipeline.git.tag >> | |
jobs: | |
- send-workflow-start-callback: | |
<<: *filters-tag-triggered-workflow-job | |
- job-hello-world: | |
<<: *filters-tag-triggered-workflow-job | |
- job-old-joe: | |
<<: *filters-tag-triggered-workflow-job | |
- job-old-joe-failure: | |
<<: *filters-tag-triggered-workflow-job | |
# - job-failure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment