diff --git a/.circleci/config.yml b/.circleci/config.yml index b21118c..4409948 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,9 @@ version: 2.1 + +orbs: + approvals: commitdev/approvals@0.0.2 + queue: eddiewebb/queue@1.4.2 + jobs: # This job is useful when you've got a large git history and you want to be able to do a single shallow checkout and then # use a workspace to persist the checked out code for later jobs in the pipeline. @@ -173,42 +178,151 @@ jobs: echo 'Hello World!' echo 'This is the delivery pipeline' + e2e_test: + docker: + - image: circleci/node:12 + parameters: + environment: + type: string + description: Environment to test. + blocking: + type: boolean + default: true + description: | + Whether this step running will block all other jobs against this environment. + steps: + - run: + command: | + sleep 120 + echo 'Done testing << parameters.environment >>' + deploy: docker: - image: circleci/python:3.8 + parameters: + environment: + type: string + description: Environment to test. + blocking: + type: boolean + default: true + description: | + Whether this step running will block all other jobs against this environment. + steps: + - approvals/get + - deploy: + name: Staging Deployment + command: | + sleep 52 + echo 'Deploying to Production approved by $WORKFLOW_APPROVER' + + post_deploy: + docker: + - image: circleci/node:12 + parameters: + environment: + type: string + description: Environment to test. + blocking: + type: boolean + default: true + description: | + Whether this step running will block all other jobs against this environment. steps: - run: - name: The First Step command: | - echo 'DEPLOYING PROD!!!' + sleep 120 + echo 'Done post-deploy for << parameters.environment >>' + + deploy_with_queue: + docker: + - image: circleci/python:3.8 + steps: + - approvals/get + - queue/until_front_of_line: + time: '10' + - deploy: + name: Staging Deployment + command: | + sleep 52 + echo 'Deploying to Production approved by $WORKFLOW_APPROVER' workflows: - approval_workflow: + approval_workflow_ENVIRONMENTS: jobs: - build - test - - wait_for_approve: - type: approval + - deploy: + name: deploy_staging + environment: staging + blocking: true requires: - build - - wait_for_approve2: - type: approval + - test + - e2e_test: + environment: staging + blocking: true requires: - - build + - deploy_staging - deploy: + name: deploy_production + environment: production + blocking: true requires: - - wait_for_approve - - wait_for_approve2 + - e2e_test + - post_deploy: + environment: production + blocking: false # Allows us to have steps run that don't block other deploys to this environment. + requires: + - deploy_production - docker_build_workflow: + approval_workflow_OTHER: jobs: - - shallow_checkout_and_save_workspace - - go_build: - requires: - - shallow_checkout_and_save_workspace - - basic_docker_build: - requires: - - go_build - - basic_docker_build_remote_docker: + - build + - test + - deploy_with_queue: requires: - - go_build + - build + + # approval_workflow_TWO: + # jobs: + # - build + # - test + # - wait_for_approve: + # type: approval + # requires: + # - build + # - queue/block_workflow: + # requires: + # - wait_for_approve + # - deploy: + # requires: + # - queue/block_workflow + + # approval_workflow_THREE: + # jobs: + # - build + # - test + # - queue/block_workflow: + # requires: + # - build + # - wait_for_approve: + # type: approval + # requires: + # - queue/block_workflow + # - deploy: + # requires: + # - wait_for_approve + + # docker_build_workflow: + # jobs: + # - shallow_checkout_and_save_workspace + # - go_build: + # requires: + # - shallow_checkout_and_save_workspace + # - basic_docker_build: + # requires: + # - go_build + # - basic_docker_build_remote_docker: + # requires: + # - go_build diff --git a/examples/commit-orbs/approvals/config.yml b/examples/commit-orbs/approvals/config.yml new file mode 100644 index 0000000..9ba57c8 --- /dev/null +++ b/examples/commit-orbs/approvals/config.yml @@ -0,0 +1,38 @@ +version: 2.1 + +orbs: + - approvals: commitdev/approvals@dev-approvals-orb + +jobs: + build: + docker: + - image: circleci/python:3.8 + steps: + - run: + name: The First Step + command: | + echo 'Hello World!' + echo 'This is the delivery pipeline' + + staging_deploy: + docker: + - image: circleci/python:3.8 + steps: + - approvals/get + - deploy: + name: Staging Deployment + command: | + echo 'DEPLOYING STAG approved by $WORKFLOW_APPROVER!!!' + +workflows: + simple_workflow: + jobs: + - build + - test + - wait_for_approve: + type: approval + requires: + - build + - deploy: + requires: + - wait_for_approve diff --git a/examples/wait-for-approval/config.yml b/examples/wait-for-approval/config.yml index dd57d80..3871eb2 100644 --- a/examples/wait-for-approval/config.yml +++ b/examples/wait-for-approval/config.yml @@ -1,4 +1,8 @@ version: 2.1 + +orbs: + queue: eddiewebb/queue@1.4.2 + jobs: build: docker: @@ -23,6 +27,10 @@ jobs: docker: - image: circleci/python:3.8 steps: + - queue/until_front_of_line: + only-on-branch: master + time: '10' + - run: echo "This job will not overlap" - deploy: name: Staging Deployment command: |