From d646eeff013b18069d4ab24c7d3b751cb5f4eeff Mon Sep 17 00:00:00 2001 From: George Hudson Date: Wed, 10 Jan 2024 08:59:13 -0700 Subject: [PATCH] 2722/circleci (#2739) * reduced workflows from 3 deploys to 1 * fix spacing of nested 'steps:' * repaired logic for workflow * trying to get right format for conditional logic in job steps * fixed incorrect variable * adding default target_env instead of emptry string * reverting * fixed spacing * removed old requirement and updated for current jobs. * use this branch to check develop deploys * use this branch to check develop deploys * use this branch to check develop deploys * use this branch to check develop deploys * use this branch to check develop deploys * use this branch to check develop deploys * revert * revert * revert * removed check in jobs * updates site only for develop branch * removed deploy develop from github actions * fixed spacing * remove this branch from CI tracking * removed 2722/circleci branch references now that testing is done --------- Co-authored-by: George Hudson Co-authored-by: Alex P <63075587+ADPennington@users.noreply.github.com> Co-authored-by: Andrew <84722778+andrew-jameson@users.noreply.github.com> --- .circleci/deployment/jobs.yml | 16 +-- .circleci/deployment/workflows.yml | 120 +++++++++--------- .github/workflows/deploy-develop-on-merge.yml | 52 -------- 3 files changed, 61 insertions(+), 127 deletions(-) delete mode 100644 .github/workflows/deploy-develop-on-merge.yml diff --git a/.circleci/deployment/jobs.yml b/.circleci/deployment/jobs.yml index 9aa40dfa7..d6faf27b8 100644 --- a/.circleci/deployment/jobs.yml +++ b/.circleci/deployment/jobs.yml @@ -1,9 +1,9 @@ # jobs: deploy-dev: - executor: docker-executor parameters: target_env: type: string + executor: docker-executor working_directory: ~/tdp-deploy steps: - deploy-cloud-dot-gov: @@ -33,26 +33,16 @@ cf-username: CF_USERNAME_STAGING deploy-infrastructure-dev: - executor: terraform/default - working_directory: ~/tdp-deploy parameters: target_env: type: string - steps: - - deploy-infrastructure: - cf-app: << parameters.target_env >> - - deploy-infrastructure-staging: executor: terraform/default working_directory: ~/tdp-deploy steps: - deploy-infrastructure: - cf-password: CF_PASSWORD_STAGING - cf-username: CF_USERNAME_STAGING - cf-space: tanf-staging - tf-path: ./terraform/staging + cf-app: << parameters.target_env >> - deploy-infrastructure-develop: + deploy-infrastructure-staging: executor: terraform/default working_directory: ~/tdp-deploy steps: diff --git a/.circleci/deployment/workflows.yml b/.circleci/deployment/workflows.yml index 5689b83bc..8a4269c04 100644 --- a/.circleci/deployment/workflows.yml +++ b/.circleci/deployment/workflows.yml @@ -1,43 +1,51 @@ #workflows: - dev-deployment: + deployment: when: - << pipeline.parameters.run_dev_deployment >> + and: + - or: + - equal: [ master, << pipeline.git.branch >> ] + - equal: [ main, << pipeline.git.branch >> ] + - equal: [ develop, << pipeline.git.branch >> ] + - << pipeline.parameters.run_dev_deployment >> + - not: << pipeline.parameters.run_nightly_owasp_scan >> + jobs: + - deploy-project-updates-site: + filters: + branches: + only: + - develop - deploy-infrastructure-dev: target_env: << pipeline.parameters.target_env >> - - enable-versioning: - requires: - - deploy-infrastructure-dev filters: branches: ignore: - develop - main - master - - deploy-dev: - target_env: << pipeline.parameters.target_env >> - requires: - - deploy-infrastructure-dev - - staging-deployment: - unless: - or: - - << pipeline.parameters.run_dev_deployment >> - - << pipeline.parameters.run_nightly_owasp_scan >> - jobs: - - deploy-project-updates-site: + - deploy-infrastructure-staging: filters: branches: only: - develop - - deploy-infrastructure-develop: + - main + - deploy-infrastructure-production: filters: branches: only: + - master + - enable-versioning: + requires: + - deploy-infrastructure-dev + filters: + branches: + ignore: - develop + - main + - master - enable-versioning: requires: - - deploy-infrastructure-develop + - deploy-infrastructure-staging target_env: develop cf-password: CF_PASSWORD_STAGING cf-username: CF_USERNAME_STAGING @@ -46,41 +54,52 @@ branches: only: - develop - - deploy-develop: + - enable-versioning: requires: - - deploy-infrastructure-develop + - deploy-infrastructure-staging + target_env: staging + cf-password: CF_PASSWORD_STAGING + cf-username: CF_USERNAME_STAGING + cf-space: tanf-staging filters: branches: only: - - develop - - test-deployment-e2e: + - main + - enable-versioning: requires: - - deploy-develop + - deploy-infrastructure-production + target_env: prod + cf-password: CF_PASSWORD_PROD + cf-username: CF_USERNAME_PROD + cf-space: tanf-prod filters: branches: only: - - develop - - make_erd: # from ../util folder + - master + - prod-deploy-clamav: + requires: + - deploy-infrastructure-production filters: branches: only: - - develop - - deploy-infrastructure-staging: + - master + - deploy-dev: + target_env: << pipeline.parameters.target_env >> + requires: + - deploy-infrastructure-dev filters: branches: - only: + ignore: + - develop - main - - enable-versioning: + - master + - deploy-develop: requires: - deploy-infrastructure-staging - target_env: staging - cf-password: CF_PASSWORD_STAGING - cf-username: CF_USERNAME_STAGING - cf-space: tanf-staging filters: branches: only: - - main + - develop - deploy-staging: requires: - deploy-infrastructure-staging @@ -88,29 +107,6 @@ branches: only: - main - - production-deployment: - unless: - or: - - << pipeline.parameters.run_dev_deployment >> - - << pipeline.parameters.run_nightly_owasp_scan >> - jobs: - - deploy-infrastructure-production: - filters: - branches: - only: - - master - - enable-versioning: - requires: - - deploy-infrastructure-production - target_env: prod - cf-password: CF_PASSWORD_PROD - cf-username: CF_USERNAME_PROD - cf-space: tanf-prod - filters: - branches: - only: - - master - deploy-production: requires: - deploy-infrastructure-production @@ -118,16 +114,16 @@ branches: only: - master - - prod-deploy-clamav: + - test-deployment-e2e: requires: - - deploy-infrastructure-production + - deploy-develop filters: branches: only: - - master + - develop - make_erd: # from ../util folder filters: branches: only: + - develop - master - diff --git a/.github/workflows/deploy-develop-on-merge.yml b/.github/workflows/deploy-develop-on-merge.yml deleted file mode 100644 index ee4eee057..000000000 --- a/.github/workflows/deploy-develop-on-merge.yml +++ /dev/null @@ -1,52 +0,0 @@ -########################################################################### -# GitHub Action Workflow -# On push to the develop branch (which should only be done through PR) -# in GitHub this action will trigger a deploy job within CircleCI for the -# deployment and e2e testing of the develop environment. -# -# Step 0: Checkout latest commit on develop -# -# Step 1: Makes a request to the V2 CircleCI API to initiate the project, -# which will filter based upon the branch to initiate the -# workflow/jobs listed here: -# staging-deployment:[ -# deploy-project-updates-site, -# deploy-infrastructure-develop, -# deploy-develop, -# test-deployment-e2e -# ] -# -# Leverages the open source GitHub Action: -# https://github.com/promiseofcake/circleci-trigger-action -########################################################################### -name: Deploy Develop on PR Merge -on: - push: - branches: - - develop - paths-ignore: - - 'docs/**' - - '**.md' - - '**.txt' - - '.gitattributes' - - '.gitignore' - - 'LICENSE' -jobs: - merge_deployment: - if: github.ref == 'refs/heads/develop' - runs-on: ubuntu-latest - name: Initiate deploy job in CircleCI - steps: - - uses: actions/checkout@v2 - - name: Circle CI Deployment Trigger - id: curl-circle-ci - uses: promiseofcake/circleci-trigger-action@v1 - with: - user-token: ${{ secrets.CIRCLE_CI_V2_TOKEN }} - project-slug: ${{ github.repository }} - branch: ${{ github.ref_name }} - payload: '{ - "develop_branch_deploy": true, - "target_env": "develop", - "triggered": true - }'