From cc0baec824e7cf12d79fccc5695ec295332c6029 Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Tue, 23 Jan 2024 14:11:52 +0000 Subject: [PATCH 01/15] BAU standardise deploy workflow --- .github/workflows/copilot_deploy.yml | 302 ++++----------------------- 1 file changed, 45 insertions(+), 257 deletions(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index 4e9c2a07..75c054c4 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -66,131 +66,42 @@ jobs: copilot_environments_workflow_setup: runs-on: ubuntu-latest outputs: - matrix: ${{ steps.copilot_env_matrix.outputs.env_list }} - pre_matrix: ${{ steps.copilot_env_matrix.outputs.pre_deploy_list }} - post_matrix: ${{ steps.copilot_env_matrix.outputs.post_deploy_list }} + env_list: ${{ steps.copilot_env_list.outputs.env_list }} + ind_list: ${{ steps.copilot_env_list.outputs.ind_list }} steps: - id: copilot_env_matrix run: | + echo "ind_list=[]" >> $GITHUB_OUTPUT + echo "env_list=[]" >> $GITHUB_OUTPUT if [ "${{ inputs.environment }}" != "" ]; then - echo "env_list=[\"${{ inputs.environment }}\"]" >> $GITHUB_OUTPUT + echo "ind_list=[\"${{ inputs.environment }}\"]" >> $GITHUB_OUTPUT elif [ "${{ github.ref }}" == 'refs/heads/main' ]; then - echo "pre_deploy_list=[\"dev\", \"test\"]" >> $GITHUB_OUTPUT - echo "post_deploy_list=[\"uat\", \"prod\"]" >> $GITHUB_OUTPUT + echo "env_list=[\"dev\", \"test\", \"uat\", \"prod\"]" >> $GITHUB_OUTPUT else - echo "pre_deploy_list=[\"dev\", \"test\"]" >> $GITHUB_OUTPUT + echo "env_list=[\"dev\", \"test\"]" >> $GITHUB_OUTPUT fi - individual_deploy: - if: inputs.environment != '' + ind_deploy: + if: ${{ needs.copilot_environments_workflow_setup.outputs.ind_list != '[]' }} concurrency: - group: 'fsd-preaward-copilot-individual-${{ matrix.value }}' + group: 'fsd-preaward-copilot-dev' cancel-in-progress: false - permissions: - id-token: write # This is required for requesting the JWT - contents: read # This is required for actions/checkout - needs: [ tag_version, pre_deploy_tests, paketo_build, copilot_environments_workflow_setup ] - runs-on: ubuntu-latest - strategy: - max-parallel: 1 - matrix: - value: ${{ fromJSON(needs.copilot_environments_workflow_setup.outputs.matrix) }} - fail-fast: false - environment: ${{ matrix.value }} - steps: - - name: Git clone the repository - uses: actions/checkout@v4 - - - name: Get current date - shell: bash - id: currentdatetime - run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT - - - name: configure aws credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/GithubCopilotDeploy - role-session-name: NOTIFICATION_${{ matrix.value }}_COPILOT_${{ steps.currentdatetime.outputs.datetime }} - aws-region: eu-west-2 - - - name: Install AWS Copilot CLI - shell: bash - run: | - curl -Lo aws-copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x aws-copilot && sudo mv aws-copilot /usr/local/bin/copilot - - - name: confirm copilot env - shell: bash - run: | - if [ $(copilot env ls) != "${{ matrix.value }}" ]; then - echo $(copilot env ls) - exit 1 - fi - - - name: Inject Git SHA into manifest - run: | - yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/fsd-notification/manifest.yml - - - name: Inject replacement image into manifest - run: | - yq -i '.image.location = "ghcr.io/communitiesuk/funding-service-design-notification:${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }}"' copilot/fsd-notification/manifest.yml - - - name: Copilot ${{ matrix.value }} deploy - id: deploy_build - run: | - copilot svc deploy --env ${{ matrix.value }} --app pre-award + uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + with: + env: 'dev' + app_name: 'notification' + version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} dev_deploy: - if: ${{ needs.copilot_environments_workflow_setup.outputs.pre_matrix != '' && toJson(fromJson(needs.copilot_environments_workflow_setup.outputs.pre_matrix)) != '[]' }} + if: ${{ contains(needs.copilot_environments_workflow_setup.outputs.env_list, 'dev') concurrency: group: 'fsd-preaward-copilot-dev' cancel-in-progress: false - permissions: - id-token: write # This is required for requesting the JWT - contents: read # This is required for actions/checkout - needs: [ tag_version, pre_deploy_tests, paketo_build, copilot_environments_workflow_setup ] - runs-on: ubuntu-latest - environment: dev - steps: - - name: Git clone the repository - uses: actions/checkout@v4 - - - name: Get current date - shell: bash - id: currentdatetime - run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT - - - name: configure aws credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/GithubCopilotDeploy - role-session-name: NOTIFICATION_DEV_COPILOT_${{ steps.currentdatetime.outputs.datetime }} - aws-region: eu-west-2 - - - name: Install AWS Copilot CLI - shell: bash - run: | - curl -Lo aws-copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x aws-copilot && sudo mv aws-copilot /usr/local/bin/copilot - - - name: confirm copilot env - shell: bash - run: | - if [ $(copilot env ls) != "dev" ]; then - echo $(copilot env ls) - exit 1 - fi - - - name: Inject Git SHA into manifest - run: | - yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/fsd-notification/manifest.yml - - - name: Inject replacement image into manifest - run: | - yq -i '.image.location = "ghcr.io/communitiesuk/funding-service-design-notification:${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }}"' copilot/fsd-notification/manifest.yml - - - name: Copilot dev deploy - id: deploy_build - run: | - copilot svc deploy --env dev --app pre-award + uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + with: + env: 'dev' + app_name: 'notification' + version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} post_dev_deploy_tests: needs: dev_deploy @@ -207,57 +118,16 @@ jobs: environment: dev test_deploy: - if: ${{ needs.copilot_environments_workflow_setup.outputs.pre_matrix != '' && toJson(fromJson(needs.copilot_environments_workflow_setup.outputs.pre_matrix)) != '[]' }} + if: ${{ contains(needs.copilot_environments_workflow_setup.outputs.env_list, 'test') concurrency: - group: 'fsd-preaward-copilot-test' + group: 'fsd-preaward-copilot-dev' cancel-in-progress: false - permissions: - id-token: write # This is required for requesting the JWT - contents: read # This is required for actions/checkout - needs: [ tag_version, post_dev_deploy_tests, paketo_build, copilot_environments_workflow_setup ] - runs-on: ubuntu-latest - environment: test - steps: - - name: Git clone the repository - uses: actions/checkout@v4 - - - name: Get current date - shell: bash - id: currentdatetime - run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT - - - name: configure aws credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/GithubCopilotDeploy - role-session-name: NOTIFICATION_TEST_COPILOT_${{ steps.currentdatetime.outputs.datetime }} - aws-region: eu-west-2 - - - name: Install AWS Copilot CLI - shell: bash - run: | - curl -Lo aws-copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x aws-copilot && sudo mv aws-copilot /usr/local/bin/copilot - - - name: confirm copilot env - shell: bash - run: | - if [ $(copilot env ls) != "test" ]; then - echo $(copilot env ls) - exit 1 - fi - - - name: Inject Git SHA into manifest - run: | - yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/fsd-notification/manifest.yml - - - name: Inject replacement image into manifest - run: | - yq -i '.image.location = "ghcr.io/communitiesuk/funding-service-design-notification:${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }}"' copilot/fsd-notification/manifest.yml - - - name: Copilot test deploy - id: deploy_build - run: | - copilot svc deploy --env test --app pre-award + uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + with: + env: 'test' + app_name: 'notification' + version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} + needs: [ tag_version, copilot_environments_workflow_setup ] post_test_deploy_tests: needs: test_deploy @@ -274,57 +144,16 @@ jobs: environment: test uat_deploy: - if: ${{ needs.copilot_environments_workflow_setup.outputs.post_matrix != '' && toJson(fromJson(needs.copilot_environments_workflow_setup.outputs.post_matrix)) != '[]' }} + if: ${{ contains(needs.copilot_environments_workflow_setup.outputs.env_list, 'uat') concurrency: - group: 'fsd-preaward-copilot-uat' + group: 'fsd-preaward-copilot-dev' cancel-in-progress: false - permissions: - id-token: write # This is required for requesting the JWT - contents: read # This is required for actions/checkout - needs: [ tag_version, post_test_deploy_tests, paketo_build, copilot_environments_workflow_setup ] - runs-on: ubuntu-latest - environment: uat - steps: - - name: Git clone the repository - uses: actions/checkout@v4 - - - name: Get current date - shell: bash - id: currentdatetime - run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT - - - name: configure aws credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/GithubCopilotDeploy - role-session-name: NOTIFICATION_UAT_COPILOT_${{ steps.currentdatetime.outputs.datetime }} - aws-region: eu-west-2 - - - name: Install AWS Copilot CLI - shell: bash - run: | - curl -Lo aws-copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x aws-copilot && sudo mv aws-copilot /usr/local/bin/copilot - - - name: confirm copilot env - shell: bash - run: | - if [ $(copilot env ls) != "uat" ]; then - echo $(copilot env ls) - exit 1 - fi - - - name: Inject Git SHA into manifest - run: | - yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/fsd-notification/manifest.yml - - - name: Inject replacement image into manifest - run: | - yq -i '.image.location = "ghcr.io/communitiesuk/funding-service-design-notification:${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }}"' copilot/fsd-notification/manifest.yml - - - name: Copilot uat deploy - id: deploy_build - run: | - copilot svc deploy --env uat --app pre-award + uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + with: + env: 'uat' + app_name: 'notification' + version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} + needs: [ tag_version, post_test_deploy_tests, copilot_environments_workflow_setup ] post_uat_deploy_tests: needs: uat_deploy @@ -341,54 +170,13 @@ jobs: environment: uat prod_deploy: - if: ${{ needs.copilot_environments_workflow_setup.outputs.post_matrix != '' && toJson(fromJson(needs.copilot_environments_workflow_setup.outputs.post_matrix)) != '[]' }} + if: ${{ contains(needs.copilot_environments_workflow_setup.outputs.env_list, 'prod') concurrency: - group: 'fsd-preaward-copilot-prod' + group: 'fsd-preaward-copilot-dev' cancel-in-progress: false - permissions: - id-token: write # This is required for requesting the JWT - contents: read # This is required for actions/checkout - needs: [ tag_version, post_uat_deploy_tests, paketo_build, copilot_environments_workflow_setup ] - runs-on: ubuntu-latest - environment: prod - steps: - - name: Git clone the repository - uses: actions/checkout@v4 - - - name: Get current date - shell: bash - id: currentdatetime - run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT - - - name: configure aws credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT }}:role/GithubCopilotDeploy - role-session-name: NOTIFICATION_PRODUCTION_COPILOT_${{ steps.currentdatetime.outputs.datetime }} - aws-region: eu-west-2 - - - name: Install AWS Copilot CLI - shell: bash - run: | - curl -Lo aws-copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x aws-copilot && sudo mv aws-copilot /usr/local/bin/copilot - - - name: confirm copilot env - shell: bash - run: | - if [ $(copilot env ls) != "prod" ]; then - echo $(copilot env ls) - exit 1 - fi - - - name: Inject Git SHA into manifest - run: | - yq -i '.variables.GITHUB_SHA = "${{ github.sha }}"' copilot/fsd-notification/manifest.yml - - - name: Inject replacement image into manifest - run: | - yq -i '.image.location = "ghcr.io/communitiesuk/funding-service-design-notification:${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }}"' copilot/fsd-notification/manifest.yml - - - name: Copilot prod deploy - id: deploy_build - run: | - copilot svc deploy --env prod --app pre-award + uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + with: + env: 'prod' + app_name: 'notification' + version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} + needs: [ tag_version, post_uat_deploy_tests, copilot_environments_workflow_setup ] From f34deb05cd989e3fc198b1953bce4f71b1d1322f Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Tue, 23 Jan 2024 14:15:48 +0000 Subject: [PATCH 02/15] Standardise the deploy and use the correct jobs for individually-specified deploys. --- .github/workflows/copilot_deploy.yml | 71 +++++++++++++--------------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index 75c054c4..f5c487fb 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -66,41 +66,41 @@ jobs: copilot_environments_workflow_setup: runs-on: ubuntu-latest outputs: - env_list: ${{ steps.copilot_env_list.outputs.env_list }} - ind_list: ${{ steps.copilot_env_list.outputs.ind_list }} + ind_deploy: ${{ steps.copilot_env_list.outputs.ind_deploy }} + pre_deploy: ${{ steps.copilot_env_list.outputs.pre_deploy }} + post_deploy: ${{ steps.copilot_env_list.outputs.post_deploy }} steps: - - id: copilot_env_matrix + - id: copilot_env_list run: | - echo "ind_list=[]" >> $GITHUB_OUTPUT - echo "env_list=[]" >> $GITHUB_OUTPUT if [ "${{ inputs.environment }}" != "" ]; then - echo "ind_list=[\"${{ inputs.environment }}\"]" >> $GITHUB_OUTPUT + echo "ind_deploy=${{ inputs.environment }}" >> $GITHUB_OUTPUT elif [ "${{ github.ref }}" == 'refs/heads/main' ]; then - echo "env_list=[\"dev\", \"test\", \"uat\", \"prod\"]" >> $GITHUB_OUTPUT + echo "pre_deploy=yes">> $GITHUB_OUTPUT + echo "post_deploy=yes">> $GITHUB_OUTPUT else - echo "env_list=[\"dev\", \"test\"]" >> $GITHUB_OUTPUT + echo "pre_deploy=yes">> $GITHUB_OUTPUT fi ind_deploy: - if: ${{ needs.copilot_environments_workflow_setup.outputs.ind_list != '[]' }} - concurrency: - group: 'fsd-preaward-copilot-dev' - cancel-in-progress: false + needs: [ pre_deploy_tests, paketo_build, tag_version, copilot_environments_workflow_setup ] + if: ${{ needs.copilot_environments_workflow_setup.outputs.ind_deploy != '' }} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + secrets: + AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: - env: 'dev' + environment: ${{ needs.copilot_environments_workflow_setup.outputs.ind_deploy }} app_name: 'notification' version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} dev_deploy: - if: ${{ contains(needs.copilot_environments_workflow_setup.outputs.env_list, 'dev') - concurrency: - group: 'fsd-preaward-copilot-dev' - cancel-in-progress: false + needs: [ pre_deploy_tests, paketo_build, tag_version, copilot_environments_workflow_setup ] + if: ${{ needs.copilot_environments_workflow_setup.outputs.pre_deploy == 'yes' }} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + secrets: + AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: - env: 'dev' - app_name: 'notification' + environment: dev + app_name: notification version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} post_dev_deploy_tests: @@ -118,16 +118,15 @@ jobs: environment: dev test_deploy: - if: ${{ contains(needs.copilot_environments_workflow_setup.outputs.env_list, 'test') - concurrency: - group: 'fsd-preaward-copilot-dev' - cancel-in-progress: false + needs: [ post_dev_deploy_tests, paketo_build, tag_version, copilot_environments_workflow_setup ] + if: ${{ needs.copilot_environments_workflow_setup.outputs.pre_deploy == 'yes' }} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + secrets: + AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: - env: 'test' + environment: 'test' app_name: 'notification' version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} - needs: [ tag_version, copilot_environments_workflow_setup ] post_test_deploy_tests: needs: test_deploy @@ -144,16 +143,15 @@ jobs: environment: test uat_deploy: - if: ${{ contains(needs.copilot_environments_workflow_setup.outputs.env_list, 'uat') - concurrency: - group: 'fsd-preaward-copilot-dev' - cancel-in-progress: false + needs: [ post_test_deploy_tests, paketo_build, tag_version, copilot_environments_workflow_setup ] + if: ${{ needs.copilot_environments_workflow_setup.outputs.post_deploy == 'yes' }} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + secrets: + AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: - env: 'uat' + environment: 'uat' app_name: 'notification' version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} - needs: [ tag_version, post_test_deploy_tests, copilot_environments_workflow_setup ] post_uat_deploy_tests: needs: uat_deploy @@ -170,13 +168,12 @@ jobs: environment: uat prod_deploy: - if: ${{ contains(needs.copilot_environments_workflow_setup.outputs.env_list, 'prod') - concurrency: - group: 'fsd-preaward-copilot-dev' - cancel-in-progress: false + needs: [ post_uat_deploy_tests, paketo_build, tag_version, copilot_environments_workflow_setup ] + if: ${{ needs.copilot_environments_workflow_setup.outputs.post_deploy == 'yes' }} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + secrets: + AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: - env: 'prod' + environment: 'prod' app_name: 'notification' version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} - needs: [ tag_version, post_uat_deploy_tests, copilot_environments_workflow_setup ] From cfbef85b753aebeae778f3d9010f33f17eb98064 Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Mon, 29 Jan 2024 09:13:07 +0000 Subject: [PATCH 03/15] Put this back --- .github/workflows/copilot_deploy.yml | 84 ++++++++++------------------ 1 file changed, 31 insertions(+), 53 deletions(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index f5c487fb..ca21a6cc 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -18,7 +18,7 @@ on: description: Run performance tests run_e2e_tests: required: false - default: true + default: false type: boolean description: Run e2e tests push: @@ -36,15 +36,22 @@ on: - '.github/workflows/copilot_deploy.yml' jobs: - tag_version: + setup: runs-on: ubuntu-latest outputs: - version_to_tag: ${{ steps.notification_tagging.outputs.tag_value }} + jobs_to_run: ${{ steps.determine-jobs.outputs.job_list }} steps: - - id: notification_tagging + - id: determine-jobs run: | - echo "tag_value=$(echo '${{ github.ref }}' | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_OUTPUT - + if [ "${{ inputs.environment }}" != '' ]; then + export jobs='["${{ inputs.environment }}"]' + elif [ "${{ github.ref }}" == 'refs/heads/main' ]; then + export jobs='["dev", "test", "uat", "prod"]' + else + export jobs='["dev", "test"]' + fi + echo "job_list=$(jq -cn --argjson keys "$jobs" '$keys')" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT pre_deploy_tests: secrets: GOV_NOTIFY_API_KEY: ${{ secrets.GOV_NOTIFY_API_KEY }} @@ -53,55 +60,26 @@ jobs: postgres_unit_testing: false paketo_build: - needs: [ tag_version ] + needs: setup concurrency: build-notification-pack permissions: packages: write uses: communitiesuk/funding-service-design-workflows/.github/workflows/package.yml@main with: - version_to_build: ${{ needs.tag_version.outputs.version_to_tag }} + version_to_build: sha-${{ github.sha }} owner: ${{ github.repository_owner }} application: funding-service-design-notification - copilot_environments_workflow_setup: - runs-on: ubuntu-latest - outputs: - ind_deploy: ${{ steps.copilot_env_list.outputs.ind_deploy }} - pre_deploy: ${{ steps.copilot_env_list.outputs.pre_deploy }} - post_deploy: ${{ steps.copilot_env_list.outputs.post_deploy }} - steps: - - id: copilot_env_list - run: | - if [ "${{ inputs.environment }}" != "" ]; then - echo "ind_deploy=${{ inputs.environment }}" >> $GITHUB_OUTPUT - elif [ "${{ github.ref }}" == 'refs/heads/main' ]; then - echo "pre_deploy=yes">> $GITHUB_OUTPUT - echo "post_deploy=yes">> $GITHUB_OUTPUT - else - echo "pre_deploy=yes">> $GITHUB_OUTPUT - fi - - ind_deploy: - needs: [ pre_deploy_tests, paketo_build, tag_version, copilot_environments_workflow_setup ] - if: ${{ needs.copilot_environments_workflow_setup.outputs.ind_deploy != '' }} - uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy - secrets: - AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} - with: - environment: ${{ needs.copilot_environments_workflow_setup.outputs.ind_deploy }} - app_name: 'notification' - version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} - dev_deploy: - needs: [ pre_deploy_tests, paketo_build, tag_version, copilot_environments_workflow_setup ] - if: ${{ needs.copilot_environments_workflow_setup.outputs.pre_deploy == 'yes' }} - uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + needs: [ pre_deploy_tests, paketo_build, setup ] + if: ${{ contains(fromJSON(needs.setup.outputs.jobs_to_run), 'dev') }} + uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: environment: dev app_name: notification - version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} + version: sha-${{ github.sha }} post_dev_deploy_tests: needs: dev_deploy @@ -118,15 +96,15 @@ jobs: environment: dev test_deploy: - needs: [ post_dev_deploy_tests, paketo_build, tag_version, copilot_environments_workflow_setup ] - if: ${{ needs.copilot_environments_workflow_setup.outputs.pre_deploy == 'yes' }} - uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + needs: [ post_dev_deploy_tests, paketo_build, setup ] + if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'test') && (needs.post_dev_deploy_tests.result == 'success' || needs.post_dev_deploy_tests.result == 'skipped') && needs.paketo_build.result == 'success' }} + uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: environment: 'test' app_name: 'notification' - version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} + version: sha-${{ github.sha }} post_test_deploy_tests: needs: test_deploy @@ -143,15 +121,15 @@ jobs: environment: test uat_deploy: - needs: [ post_test_deploy_tests, paketo_build, tag_version, copilot_environments_workflow_setup ] - if: ${{ needs.copilot_environments_workflow_setup.outputs.post_deploy == 'yes' }} - uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + needs: [ post_test_deploy_tests, paketo_build, setup ] + if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'uat') && (needs.post_test_deploy_tests.result == 'success' || needs.post_test_deploy_tests.result == 'skipped') && needs.paketo_build.result == 'success' }} + uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: environment: 'uat' app_name: 'notification' - version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} + version: sha-${{ github.sha }} post_uat_deploy_tests: needs: uat_deploy @@ -168,12 +146,12 @@ jobs: environment: uat prod_deploy: - needs: [ post_uat_deploy_tests, paketo_build, tag_version, copilot_environments_workflow_setup ] - if: ${{ needs.copilot_environments_workflow_setup.outputs.post_deploy == 'yes' }} - uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@BAU_standardise_deploy + needs: [ post_uat_deploy_tests, paketo_build, setup ] + if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'prod') && (needs.post_uat_deploy_tests.result == 'success' || needs.post_uat_deploy_tests.result == 'skipped') && needs.paketo_build.result == 'success' }} + uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: environment: 'prod' app_name: 'notification' - version: ${{ github.ref_name == 'main' && 'latest' || needs.tag_version.outputs.version_to_tag }} + version: sha-${{ github.sha }} From 9f0b3657f1a44716178b4d7f4194915eaeab023a Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Mon, 29 Jan 2024 11:35:43 +0000 Subject: [PATCH 04/15] Use common needs.* mechanism --- .github/workflows/copilot_deploy.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index ca21a6cc..47c358f5 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -96,8 +96,8 @@ jobs: environment: dev test_deploy: - needs: [ post_dev_deploy_tests, paketo_build, setup ] - if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'test') && (needs.post_dev_deploy_tests.result == 'success' || needs.post_dev_deploy_tests.result == 'skipped') && needs.paketo_build.result == 'success' }} + needs: [ dev_deploy, post_dev_deploy_tests, paketo_build, setup ] + if: ${{ always() && contains(fromJSON(needs.setup_job_list.outputs.jobs_to_run), 'test') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} @@ -121,8 +121,8 @@ jobs: environment: test uat_deploy: - needs: [ post_test_deploy_tests, paketo_build, setup ] - if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'uat') && (needs.post_test_deploy_tests.result == 'success' || needs.post_test_deploy_tests.result == 'skipped') && needs.paketo_build.result == 'success' }} + needs: [ dev_deploy, post_dev_deploy_tests, test_deploy, post_test_deploy_tests, paketo_build, setup ] + if: ${{ always() && contains(fromJSON(needs.setup_job_list.outputs.jobs_to_run), 'uat') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} @@ -146,8 +146,8 @@ jobs: environment: uat prod_deploy: - needs: [ post_uat_deploy_tests, paketo_build, setup ] - if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'prod') && (needs.post_uat_deploy_tests.result == 'success' || needs.post_uat_deploy_tests.result == 'skipped') && needs.paketo_build.result == 'success' }} + needs: [ dev_deploy, post_dev_deploy_tests, test_deploy, post_test_deploy_tests, uat_deploy, post_uat_deploy_tests, paketo_build, setup ] + if: ${{ always() && contains(fromJSON(needs.setup_job_list.outputs.jobs_to_run), 'prod') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} From 454be42b80cd3d9ac4714f75092d57022e337db9 Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Mon, 29 Jan 2024 11:54:22 +0000 Subject: [PATCH 05/15] Use common needs.* mechanism --- .github/workflows/copilot_deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index 47c358f5..a73a4364 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -97,7 +97,7 @@ jobs: test_deploy: needs: [ dev_deploy, post_dev_deploy_tests, paketo_build, setup ] - if: ${{ always() && contains(fromJSON(needs.setup_job_list.outputs.jobs_to_run), 'test') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} + if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'test') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} @@ -122,7 +122,7 @@ jobs: uat_deploy: needs: [ dev_deploy, post_dev_deploy_tests, test_deploy, post_test_deploy_tests, paketo_build, setup ] - if: ${{ always() && contains(fromJSON(needs.setup_job_list.outputs.jobs_to_run), 'uat') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} + if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'uat') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} @@ -147,7 +147,7 @@ jobs: prod_deploy: needs: [ dev_deploy, post_dev_deploy_tests, test_deploy, post_test_deploy_tests, uat_deploy, post_uat_deploy_tests, paketo_build, setup ] - if: ${{ always() && contains(fromJSON(needs.setup_job_list.outputs.jobs_to_run), 'prod') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} + if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'prod') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} uses: communitiesuk/funding-service-design-workflows/.github/workflows/standard-deploy.yml@main secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} From 9786f9a2e0447aa4d97640ee29cfb71d8f1e2e2d Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Mon, 29 Jan 2024 14:47:26 +0000 Subject: [PATCH 06/15] Amendments following review --- .github/workflows/copilot_deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index a73a4364..22c02489 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -16,9 +16,10 @@ on: default: false type: boolean description: Run performance tests + run-name: AWS Deploy ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'Dev-Test-UAT-Prod' || 'Dev-Test') }} run_e2e_tests: required: false - default: false + default: true type: boolean description: Run e2e tests push: From 8ff4e9814e68d5b64cc2114523c07dc107698199 Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Mon, 29 Jan 2024 14:51:18 +0000 Subject: [PATCH 07/15] Amendments following review --- .github/workflows/copilot_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index 22c02489..d9039fbe 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -16,7 +16,7 @@ on: default: false type: boolean description: Run performance tests - run-name: AWS Deploy ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'Dev-Test-UAT-Prod' || 'Dev-Test') }} + run-name: AWS Deploy ${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'Dev-Test-UAT-Prod' || 'Dev-Test') }} run_e2e_tests: required: false default: true From d7a68bcbfe3c79e75772c70cf1750a14dbee227b Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Mon, 29 Jan 2024 14:51:45 +0000 Subject: [PATCH 08/15] Amendments following review --- .github/workflows/copilot_deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index d9039fbe..30431a26 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -16,7 +16,6 @@ on: default: false type: boolean description: Run performance tests - run-name: AWS Deploy ${{ github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'Dev-Test-UAT-Prod' || 'Dev-Test') }} run_e2e_tests: required: false default: true From 88b8ce8e803f6588b969c9ff352ca83c31434fef Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Mon, 29 Jan 2024 14:53:50 +0000 Subject: [PATCH 09/15] Amendments following review --- .github/workflows/copilot_deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index 30431a26..f54e3692 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -1,4 +1,6 @@ name: Deploy to AWS +run-name: AWS Deploy ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || (github.ref == 'refs/heads/main' && 'Dev-Test-UAT-Prod' || 'Dev-Test') }} + on: workflow_dispatch: inputs: From 672a3d6c60ed1ec9153d6edfdf6c48e142f797cf Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Mon, 29 Jan 2024 15:37:01 +0000 Subject: [PATCH 10/15] Amendments following review --- .github/workflows/copilot_deploy.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index f54e3692..69a6e21b 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -109,7 +109,8 @@ jobs: version: sha-${{ github.sha }} post_test_deploy_tests: - needs: test_deploy + needs: [ dev_deploy, post_dev_deploy_tests, test_deploy, paketo_build, setup ] + if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'test') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} concurrency: group: 'fsd-preaward-test-test' cancel-in-progress: false @@ -134,7 +135,8 @@ jobs: version: sha-${{ github.sha }} post_uat_deploy_tests: - needs: uat_deploy + needs: [ dev_deploy, post_dev_deploy_tests, test_deploy, post_test_deploy_tests, uat_deploy, paketo_build, setup ] + if: ${{ always() && contains(fromJSON(needs.setup.outputs.jobs_to_run), 'uat') && (! contains(needs.*.result, 'failure') ) && (! contains(needs.*.result, 'cancelled') )}} concurrency: group: 'fsd-preaward-test-uat' cancel-in-progress: false From fa3cc32e835dcdadeb8503046ac5a5bc1d57f1d6 Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Thu, 1 Feb 2024 08:08:18 +0000 Subject: [PATCH 11/15] BAU standardise deploy mechanism between envs --- .github/workflows/copilot_deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index 69a6e21b..9616dc68 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -54,6 +54,7 @@ jobs: fi echo "job_list=$(jq -cn --argjson keys "$jobs" '$keys')" >> $GITHUB_OUTPUT cat $GITHUB_OUTPUT + pre_deploy_tests: secrets: GOV_NOTIFY_API_KEY: ${{ secrets.GOV_NOTIFY_API_KEY }} From b483036add10b113d14bbe8c0e0b4ab201bb2d5d Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Thu, 1 Feb 2024 08:48:27 +0000 Subject: [PATCH 12/15] BAU standardise deploy mechanism between envs --- .github/workflows/copilot_deploy.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index 9616dc68..3289c67e 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -63,7 +63,7 @@ jobs: postgres_unit_testing: false paketo_build: - needs: setup + needs: [ setup ] concurrency: build-notification-pack permissions: packages: write @@ -105,8 +105,8 @@ jobs: secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: - environment: 'test' - app_name: 'notification' + environment: test + app_name: notification version: sha-${{ github.sha }} post_test_deploy_tests: @@ -131,8 +131,8 @@ jobs: secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: - environment: 'uat' - app_name: 'notification' + environment: uat + app_name: notification version: sha-${{ github.sha }} post_uat_deploy_tests: @@ -157,6 +157,6 @@ jobs: secrets: AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} with: - environment: 'prod' - app_name: 'notification' + environment: prod + app_name: notification version: sha-${{ github.sha }} From 96118a8c8b46d463bd294fa4681288124e5146f5 Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Thu, 1 Feb 2024 09:32:05 +0000 Subject: [PATCH 13/15] BAU standardise deploy mechanism between envs --- .github/workflows/copilot_deploy.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index 3289c67e..6ef8f897 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -18,7 +18,12 @@ on: default: false type: boolean description: Run performance tests - run_e2e_tests: + run_e2e_tests_assessment: + required: false + default: true + type: boolean + description: Run e2e tests + run_e2e_tests_application: required: false default: true type: boolean @@ -95,7 +100,8 @@ jobs: uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main with: run_performance_tests: ${{ inputs.run_performance_tests || true }} - run_e2e_tests: ${{ inputs.run_e2e_tests || false }} + run_e2e_tests_assessment: ${{ inputs.run_e2e_tests || false }} + run_e2e_tests_application: ${{ inputs.run_e2e_tests || false }} environment: dev test_deploy: @@ -121,7 +127,8 @@ jobs: uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main with: run_performance_tests: ${{ inputs.run_performance_tests || true }} - run_e2e_tests: ${{ inputs.run_e2e_tests || true }} + run_e2e_tests_assessment: ${{ inputs.run_e2e_tests || false }} + run_e2e_tests_application: ${{ inputs.run_e2e_tests || true }} environment: test uat_deploy: @@ -147,7 +154,8 @@ jobs: uses: communitiesuk/funding-service-design-workflows/.github/workflows/post-deploy.yml@main with: run_performance_tests: ${{ inputs.run_performance_tests || false }} - run_e2e_tests: ${{ inputs.run_e2e_tests || true }} + run_e2e_tests_assessment: ${{ inputs.run_e2e_tests || false }} + run_e2e_tests_application: ${{ inputs.run_e2e_tests || true }} environment: uat prod_deploy: From c2cffdc129085d301d6ced2188310bccd2522b02 Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Thu, 1 Feb 2024 09:33:43 +0000 Subject: [PATCH 14/15] BAU standardise deploy mechanism between envs --- .github/workflows/copilot_deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index 6ef8f897..622ed69f 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -20,12 +20,12 @@ on: description: Run performance tests run_e2e_tests_assessment: required: false - default: true + default: false type: boolean description: Run e2e tests run_e2e_tests_application: required: false - default: true + default: false type: boolean description: Run e2e tests push: From dcb21ce86035bb4e9c57913e3e3cf97e58da97e8 Mon Sep 17 00:00:00 2001 From: Robert Kibble Date: Thu, 1 Feb 2024 09:34:05 +0000 Subject: [PATCH 15/15] BAU standardise deploy mechanism between envs --- .github/workflows/copilot_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/copilot_deploy.yml b/.github/workflows/copilot_deploy.yml index 622ed69f..29e4d348 100644 --- a/.github/workflows/copilot_deploy.yml +++ b/.github/workflows/copilot_deploy.yml @@ -25,7 +25,7 @@ on: description: Run e2e tests run_e2e_tests_application: required: false - default: false + default: true type: boolean description: Run e2e tests push: